[development] Saving admin settings

John Fiala jcfiala at gmail.com
Tue Jun 22 19:14:54 UTC 2010


Well, my initial idea would be to check the variables table to see if
anything's been written to 'active'.  By default, it's going to use
the right-most name in the form structure to refer to the fields.

I think you might want to set $form['#tree'] = TRUE;

>
> I minimized the form earlier to see if it was bad form structure, so it's a
> small paste. The problem is that in conjunction with the value always being
> the default value, the Variables table doesn't contain any field data from
> this form.
>
> function myform_admin_settings() {
>  $form = array();
>
>    foreach ($foos as $foo) {
>      $form['myform'][$foo['id']] = array(
>        '#type' => 'fieldset',
>        '#title' => t($foo['id']),
>        '#collapsible' => TRUE,
>        '#collapsed' => TRUE,
>      );
>      $form['myform'][$foo['id']]['active'] = array(
>        '#type' => 'checkbox',
>        '#title' => t('Active'),
>        '#default_value' => variable_get('myform'.$foo['id']['active'],true),
>      );
>    }
>  return system_settings_form($form);
>
> }
>
>



-- 
John Fiala
www.jcfiala.net


More information about the development mailing list