Related topics
- Form generation
- Functions to enable the processing and display of HTML forms.
File
- includes/form.inc, line 1932
Code
function expand_checkboxes($element) {
$value = is_array($element['#value']) ? $element['#value'] : array();
$element['#tree'] = TRUE;
if (count($element['#options']) > 0) {
if (!isset($element['#default_value']) || $element['#default_value'] == 0) {
$element['#default_value'] = array();
}
foreach ($element['#options'] as $key => $choice) {
if (!isset($element[$key])) {
$element[$key] = array(
'#type' => 'checkbox',
'#processed' => TRUE,
'#title' => $choice,
'#return_value' => $key,
'#default_value' => isset($value[$key]),
'#attributes' => $element['#attributes'],
'#ahah' => isset($element['#ahah']) ? $element['#ahah'] : NULL,
);
}
}
}
return $element;
}
Login or
register to post comments
Comments
Function was renamed in Drupal 7
In case someone is looking for it, the function was renamed to form_process_checkboxes in Drupal 7.
http://api.drupal.org/api/function/form_process_checkboxes/7