function views_handler_filter::group_form

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

File

handlers/views_handler_filter.inc, line 807

Class

views_handler_filter
Base class for filters.

Code

public 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 = variable_get('views_exposed_filter_any_label', 'new_any') == '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'][$value])) {
                $form_state['input'][$value] = $this->group_info;
            }
        }
        $this->options['expose']['label'] = '';
    }
}