form_process_checkboxes
function form_process_checkboxes
form_process_checkboxes($element)
Processes a checkboxes form element.
Related topics
File
- includes/form.inc, line 3313
- Functions for form and batch generation and processing.
Code
function form_process_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(); } $weight = 0; foreach ($element['#options'] as $key => $choice) { // Integer 0 is not a valid #return_value, so use '0' instead. // @see form_type_checkbox_value(). // @todo For Drupal 8, cast all integer keys to strings for consistency // with form_process_radios(). if ($key === 0) { $key = '0'; } // Maintain order of options as defined in #options, in case the element // defines custom option sub-elements, but does not define all option // sub-elements. $weight += 0.001; $element += array($key => array()); $element[$key] += array( '#type' => 'checkbox', '#title' => $choice, '#return_value' => $key, '#default_value' => isset($value[$key]) ? $key : NULL, '#attributes' => $element['#attributes'], '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL, '#weight' => $weight, ); } } return $element; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!form.inc/function/form_process_checkboxes/7.x