[development] Disapearing $form_values

Adam Gregory arcaneadam at gmail.com
Fri Feb 12 15:50:31 UTC 2010


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/fa4fdfc3/attachment.html 


More information about the development mailing list