1 views_handler_filter.inc views_handler_filter::group_form(&$form, &$form_state)

Build a form containing a group of operator | values to apply as a single filter.

File

core/modules/views/handlers/views_handler_filter.inc, line 716
@todo.

Class

views_handler_filter
Base class for filters.

Code

function group_form(&$form, &$form_state) {
  if (!empty($this->options['group_info']['optional']) && !$this->multiple_exposed_input()) {

    $old_any = $this->options['group_info']['widget'] == 'select' ? '<Any>' : '&lt;Any&gt;';
    $any_label = config_get('views.settings', 'exposed_filter_any_label') == 'old_any' ? $old_any : t('- Any -');
    $groups = array('All' => $any_label);
  }
  foreach ($this->options['group_info']['group_items'] as $id => $group) {
    if (!empty($group['title'])) {
      $groups[$id] = $id != 'All' ? t($group['title']) : $group['title'];
    }
  }

  if (count($groups)) {
    $value = $this->options['group_info']['identifier'];

    $form[$value] = array(
      '#type' => $this->options['group_info']['widget'],
      '#default_value' => $this->group_info,
      '#options' => $groups,
    );
    if (!empty($this->options['group_info']['multiple'])) {
      if (count($groups) < 5) {
        $form[$value]['#type'] = 'checkboxes';
      }
      else {
        $form[$value]['#type'] = 'select';
        $form[$value]['#size'] = 5;
        $form[$value]['#multiple'] = TRUE;
      }
      unset($form[$value]['#default_value']);
      if (empty($form_state['input'])) {
        $form_state['input'][$value] = $this->group_info;
      }
    }

    $this->options['expose']['label'] = '';
  }
}