I have created a form in the admin.
$form['things'] = array(
'#prefix' => '<div id="things">',
'#suffix' => '</div>',
'#tree' => TRUE,
'#theme' => 'table',
'#header' => array(t('Field Label'), t('Field Name'), t('Location'), t('Stuff')),
'#rows' => array(),
);
I then add each row to it like:
foreach ($type_fields as $field_name => $attrs) {
$stuff = array(
'#type' => 'textfield',
'#default_value' => $attrs['stuff'],
);
$form['things']['#rows'][] = array(
array('data' => 'label'),
array('data' => $field_name),
array('data' => $field_name),
array('data' => $stuff),
);
}
The form looks great! But the first problem is the value assigned to #default_value
is not showing up in the form. When I change it to #value
the correct value DOES show up. So I wonder how this should be done? The Drupal documentation says #value
should not be used with forms although it is functioning exactly how I would expect it to function.
The main problem is when I fill in some test data in one of the textfields and submit it: I do not see any of the submitted values in my _submit
function.
Neither $form
nor $form_state
contains any of the values I input into the text fields.
I wonder if this is because I am rendering #theme => "table"
? Has any one ran into this issue? Any Ideas on changes I can make that would allow me to see the values I am inputting when I post the form to the _submit
function?