I'm creating a form using Drupal's form API. This form includes about 50 or so checkboxes that I'm creating using the type 'checkbox'. The checkboxes are grouped using several fieldset elements. The checkbox is created from a look using an XML file that decides what checkboxes will appear.
$ageKey = '08';
$course = 'y';
$form['events'][$ageKey][$course] = array(
'#type' => 'fieldset',
'#title' => 'Set of checkboxes'
}
foreach($xCourse->event as $event) {
$eventKey = (int)$event['distance'] .'-' . (int)$event['event'];
$form['events'][$ageKey][$course][$ageKey . ' ' . $course . ' ' . $eventKey] = array(
'#type' => 'checkbox',
'#title' => (int)$event['distance'] . ' ' . $top5->dispStroke((int)$event['stroke']),
'#default_value' => 1,
);
}
I'm using hook_submit to process the form
function import_form_submit($form, &$form_state) {
$checkboxes = $form_state['values'];
//do stuff here
}
However, I find that the value for all my checkboxes is 0, regardless if the checkbox was unchecked by me or not. If I remove '#default_value' => 1
from the checkbox definition, none of the checkboxes are checked by default. The values array also appears to ignore the hierarchy I set up.
How do I get the checked state of the checkbox in my submission code? What am I missing here?