array( '#checkall' => FALSE, '#process' => array('checkall_element_process'), ), ); } /** * Process the checkall extension for the checkboxes element. */ function checkall_element_process($element) { // See if the #checkall flag is present. if (!empty($element['#checkall'])) { $class = is_string($element['#checkall']) ? trim($element['#checkall']) : ''; if (empty($class)) { $class = 'checkall-'. $element['#id']; } // Append classes to the checkboxes element. if (!isset($element['#attributes'])) { $element['#attributes'] = array(); } if (empty($element['#attributes']['class'])) { $element['#attributes']['class'] = 'form-checkall '. $class; } else { $element['#attributes']['class'] .= ' form-checkall '. $class; } // Append class to the checkboxes items. foreach (element_children($element) as $key) { if ($element[$key]['#type'] == 'checkbox') { if (!isset($element[$key]['#attributes'])) { $element[$key]['#attributes'] = array(); } if (empty($element[$key]['#attributes']['class'])) { $element[$key]['#attributes']['class'] = $class; } else { $element[$key]['#attributes']['class'] .= ' '. $class; } } } // Append the unique checkboxes class to Drupal.settings.checkall. drupal_add_js(array('checkall' => array('groups' => $class)), 'setting'); // Add our stylesheet and javascript files to the page. drupal_add_css(drupal_get_path('module', 'checkall') .'/checkall.css'); drupal_add_js(drupal_get_path('module', 'checkall') .'/checkall.js'); } return $element; }