function FilterPluginBase::group_form in Views (for Drupal 7) 8.3
Build a form containing a group of operator | values to apply as a single filter.
File
- lib/
Drupal/ views/ Plugin/ views/ filter/ FilterPluginBase.php, line 707 - Definition of Drupal\views\Plugin\views\filter\FilterPluginBase.
Class
- FilterPluginBase
- Base class for filters.
Namespace
Drupal\views\Plugin\views\filterCode
function group_form(&$form, &$form_state) {
if (!empty($this->options['group_info']['optional']) && !$this
->multipleExposedInput()) {
$old_any = $this->options['group_info']['widget'] == 'select' ? '<Any>' : '<Any>';
$any_label = config('views.settings')
->get('ui.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'] = '';
}
}