function expand_checkboxes

6.x form.inc expand_checkboxes($element)

Related topics

2 string references to 'expand_checkboxes'
system_elements in drupal-6.x/modules/system/system.module
Implementation of hook_elements().
system_modules in drupal-6.x/modules/system/system.admin.inc
Menu callback; provides module enable/disable interface.

File

drupal-6.x/includes/form.inc, line 1938

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;
}