protected function BooleanOperator::valueForm in Drupal 8
Same name and namespace in other branches
- 9 core/modules/views/src/Plugin/views/filter/BooleanOperator.php \Drupal\views\Plugin\views\filter\BooleanOperator::valueForm()
Options form subform for setting options.
This should be overridden by all child classes and it must define $form['value']
Overrides FilterPluginBase::valueForm
See also
buildOptionsForm()
File
- core/
modules/ views/ src/ Plugin/ views/ filter/ BooleanOperator.php, line 148
Class
- BooleanOperator
- Simple filter to handle matching of boolean values
Namespace
Drupal\views\Plugin\views\filterCode
protected function valueForm(&$form, FormStateInterface $form_state) {
if (empty($this->valueOptions)) {
// Initialize the array of possible values for this filter.
$this
->getValueOptions();
}
if ($exposed = $form_state
->get('exposed')) {
// Exposed filter: use a select box to save space.
$filter_form_type = 'select';
}
else {
// Configuring a filter: use radios for clarity.
$filter_form_type = 'radios';
}
$form['value'] = [
'#type' => $filter_form_type,
'#title' => $this->value_value,
'#options' => $this->valueOptions,
'#default_value' => $this->value,
];
if (!empty($this->options['exposed'])) {
$identifier = $this->options['expose']['identifier'];
$user_input = $form_state
->getUserInput();
if ($exposed && !isset($user_input[$identifier])) {
$user_input[$identifier] = $this->value;
$form_state
->setUserInput($user_input);
}
// If we're configuring an exposed filter, add an - Any - option.
if (!$exposed || empty($this->options['expose']['required'])) {
$form['value']['#options'] = [
'All' => $this
->t('- Any -'),
] + $form['value']['#options'];
}
}
}