[development] Disapearing $form_values

Adam Gregory arcaneadam at gmail.com
Fri Feb 12 18:31:35 UTC 2010


Oh duh, I totally glossed over that. Yeah in Drupal 6 form values are no
longer stored in the $form_values variable and are now stored in the
$form_state['values'] array
-----
Adam A. Gregory
Drupal Developer & Consultant
Web: AdamAGregory.com
Twitter: twitter.com/adamgregory
Phone: 910.808.1717
Cell: 706.761.7375


On Fri, Feb 12, 2010 at 1:29 PM, ktt <kestutis98 at yahoo.com> wrote:

> Hello,
>
> Sorry if the question appeared too trivial. I tried
>  "$form_values['listname']['list_name']" before with no success. Strangely.
>
> This worked for me - with "$form_values = $form_state['values'];"
>
> function contactlistcreate_submit($form, &$form_state) {
>  $form_values = $form_state['values'];
>   db_query(
>    "INSERT INTO {contactsliststable} (contacts_list_name,
> contacts_list_description) VALUES ('%s', '%s')", $form_values['list_name'],
> $form_values['description']);
>    drupal_set_message(t('Your list has been saved.'));
> }
>
> Thank you for benevolent answers.
>
> Regards,
> Ktt
> --- On Fri, 2/12/10, Adam Gregory <arcaneadam at gmail.com> wrote:
>
> > From: Adam Gregory <arcaneadam at gmail.com>
> > Subject: Re: [development] Disapearing $form_values
> > To: development at drupal.org
> > Date: Friday, February 12, 2010, 5:50 PM
> > Really that's how we roll on the Dev
> > list now? "Hey thanks for coming, now get out."
> > Esspecially when the answer is pretty simple.
> >
> > Ktt,
> >
> > The reason you are not inserting values is the
> > '#tree' => TRUE, attribute set in your fieldset.
> > This means that subsequent values will retain the array tree
> > in $form_values. Therefore your  $form_values in the
> > db_query should look like this,
> > $form_values['listname']['list_name'],
> > $form_values['listname']['description'].
> >
> >
> >
> > I hope that helps.
> > -----
> > Adam A. Gregory
> > Drupal Developer & Consultant
> > Web: AdamAGregory.com
> > Twitter: twitter.com/adamgregory
> > Phone: 910.808.1717
> >
> >
> > Cell: 706.761.7375
> >
> >
> >
> > On Fri, Feb 12, 2010 at 10:40 AM,
> > Steven Jones <steven.jones at computerminds.co.uk>
> > wrote:
> >
> >
> > Hello ktt,
> >
> >
> >
> > Please see: http://drupal.org/support
> > for your support options.
> >
> >
> >
> > Regards
> >
> > Steven Jones
> >
> > ComputerMinds ltd - Perfect Drupal Websites
> >
> >
> >
> > Phone : 024 7666 7277
> >
> > Mobile : 07702 131 576
> >
> > Twitter : darthsteven
> >
> > http://www.computerminds.co.uk
> >
> >
> >
> >
> >
> >
> >
> > On 12 February 2010 15:36, ktt <kestutis98 at yahoo.com>
> > wrote:
> >
> > > Hello,
> >
> > >
> >
> > > I have a form:
> >
> > >
> >
> > > function contactlistcreate() {
> >
> > >  $form = array();
> >
> > >
> >
> > >  $form['listname'] = array(
> >
> > >    '#type' => 'fieldset',
> >
> > >    '#title' => t('Create new
> > list'),
> >
> > >    '#tree' => TRUE,
> >
> > >  );
> >
> > >  $form['listname']['list_name'] =
> > array(
> >
> > >    '#type' => 'textfield',
> >
> > >    '#title' => t('List name'),
> >
> > >    '#size' => 30,
> >
> > >    '#maxlength' => 64,
> >
> > >    '#description' => t('Enter the
> > list name'),
> >
> > >    '#default_value' =>
> > 'dddodododod',
> >
> > >  );
> >
> > >  $form['listname']['description'] =
> > array(
> >
> > >    '#type' => 'textarea',
> >
> > >    '#title' => t('Describe it'),
> >
> > >    '#cols' => 60,
> >
> > >    '#rows' => 5,
> >
> > >    '#description' => t('List
> > description.'),
> >
> > >  );
> >
> > >  $form['listname']['submit'] =
> > array('#type' => 'submit',
> > '#value' => t('Save'));
> >
> > >  return $form;
> >
> > > }
> >
> > >
> >
> > > and submit function:
> >
> > >
> >
> > > function contactlistcreate_submit($form_id,
> > $form_values) {
> >
> > >  db_query(
> >
> > >    "INSERT INTO {contactsliststable}
> > (contacts_list_name, contacts_list_description) VALUES
> > ('%s', '%s')",
> > $form_values['list_name'],
> > $form_values['description']);
> >
> > >    drupal_set_message(t('Your list has been
> > saved.'));
> >
> > > }
> >
> > >
> >
> > > But it inserts only empty values to database table and
> > throw no errors..
> >
> > >
> >
> > >
> >
> > > Regards,
> >
> > > Ktt
> >
> > >
> >
> > >
> >
> > >
> >
> > >
> >
> >
> >
> >
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20100212/a7c807c2/attachment.html 


More information about the development mailing list