Form API + Module: Nested default value variable_get doesnt behave the same as unnested variable_get Heres the example code:

function mymodule_form($form, &amp;$form_state){
    $form['nest'] = array(
        '#type' =&gt; 'fieldset',
        '#title' =&gt; t('Nested settings'),
        '#tree' =&gt; TRUE,
    );

    $form['nest']['nested_example_item'] = array(
        '#type' =&gt; 'textfield',
        '#title' =&gt; t('Nested Example Item'),
        '#default_value' =&gt; variable_get('nested_example_item', 'example value 1'),
        '#size' =&gt; 60,
        '#maxlength' =&gt; 128,
        '#description' =&gt; t('Nested Example Item'),
    );

    $form['unnested_example_item'] = array(
        '#type' =&gt; 'textfield',
        '#title' =&gt; t('Unnested Example Item'),
        '#default_value' =&gt; variable_get('unnested_example_item', 'example value 2'),
        '#size' =&gt; 60,
        '#maxlength' =&gt; 128,
        '#description' =&gt; t('Unnested Example Item'),
    );

    return system_settings_form($form);    }


Now what happens when i change both values and submit the form is the following:


The unnested field behaves like expected - it reflects the changes.
The nested field item, does not show this behaviour, does not reflect the changes


I am confused, should I treat the nested variable_get differently?
I'm pretty sure system_settings_form() only looks for variables defined at the root of the $form_state['values'] array.

Since you have '#tree' =&gt; TRUE on your fieldset element this will not be the case. If you remove the '#tree' =&gt; TRUE' line, the value of your nested element will be saved in a variable called 'unnested_example_item' as you expect.