function FilterPluginBase::validateExposeForm
Same name in other branches
- 9 core/modules/views/src/Plugin/views/filter/FilterPluginBase.php \Drupal\views\Plugin\views\filter\FilterPluginBase::validateExposeForm()
- 8.9.x core/modules/views/src/Plugin/views/filter/FilterPluginBase.php \Drupal\views\Plugin\views\filter\FilterPluginBase::validateExposeForm()
- 11.x core/modules/views/src/Plugin/views/filter/FilterPluginBase.php \Drupal\views\Plugin\views\filter\FilterPluginBase::validateExposeForm()
Validate the options form.
Overrides HandlerBase::validateExposeForm
1 call to FilterPluginBase::validateExposeForm()
- FilterPluginBase::validateOptionsForm in core/
modules/ views/ src/ Plugin/ views/ filter/ FilterPluginBase.php - Simple validate handler.
File
-
core/
modules/ views/ src/ Plugin/ views/ filter/ FilterPluginBase.php, line 700
Class
- FilterPluginBase
- Base class for Views filters handler plugins.
Namespace
Drupal\views\Plugin\views\filterCode
public function validateExposeForm($form, FormStateInterface $form_state) {
$identifier = $form_state->getValue([
'options',
'expose',
'identifier',
]);
$this->validateIdentifier($identifier, $form_state, $form['expose']['identifier']);
$limit_operators = $form_state->getValue([
'options',
'expose',
'operator_limit_selection',
]);
$operators_selected = $form_state->getValue([
'options',
'expose',
'operator_list',
]);
$selected_operator = $form_state->getValue([
'options',
'operator',
]);
if ($limit_operators && !in_array($selected_operator, $operators_selected, TRUE)) {
$form_state->setError($form['expose']['operator_list'], $this->t('You selected the "@operator" operator as the default value but is not included in the list of limited operators.', [
'@operator' => $this->operatorOptions()[$selected_operator],
]));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.