function FilterPluginBase::buildGroupValidate
Same name in other branches
- 9 core/modules/views/src/Plugin/views/filter/FilterPluginBase.php \Drupal\views\Plugin\views\filter\FilterPluginBase::buildGroupValidate()
- 8.9.x core/modules/views/src/Plugin/views/filter/FilterPluginBase.php \Drupal\views\Plugin\views\filter\FilterPluginBase::buildGroupValidate()
- 10 core/modules/views/src/Plugin/views/filter/FilterPluginBase.php \Drupal\views\Plugin\views\filter\FilterPluginBase::buildGroupValidate()
Validate the build group options form.
1 call to FilterPluginBase::buildGroupValidate()
- 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 758
Class
- FilterPluginBase
- Base class for Views filters handler plugins.
Namespace
Drupal\views\Plugin\views\filterCode
protected function buildGroupValidate($form, FormStateInterface $form_state) {
if (!$form_state->isValueEmpty([
'options',
'group_info',
])) {
$identifier = $form_state->getValue([
'options',
'group_info',
'identifier',
]);
$this->validateIdentifier($identifier, $form_state, $form['group_info']['identifier']);
}
if ($group_items = $form_state->getValue([
'options',
'group_info',
'group_items',
])) {
foreach ($group_items as $id => $group) {
if (empty($group['remove'])) {
$has_valid_value = $this->hasValidGroupedValue($group);
if ($has_valid_value && $group['title'] == '') {
if (!method_exists($this, 'operators')) {
throw new \LogicException(get_class($this) . '::operators() not implemented');
}
if (!$this instanceof FilterOperatorsInterface) {
@trigger_error('Implementing operators() in class ' . get_class($this) . ' without it implementing \\Drupal\\views\\Plugin\\views\\filter\\FilterOperatorsInterface is deprecated in drupal:10.3.0 and will throw a LogicException in drupal:12.0.0. See https://www.drupal.org/node/3412013', E_USER_DEPRECATED);
}
$operators = $this->operators();
if ($operators[$group['operator']]['values'] == 0) {
$form_state->setError($form['group_info']['group_items'][$id]['title'], $this->t('A label is required for the specified operator.'));
}
else {
$form_state->setError($form['group_info']['group_items'][$id]['title'], $this->t('A label is required if the value for this item is defined.'));
}
}
if (!$has_valid_value && $group['title'] != '') {
$form_state->setError($form['group_info']['group_items'][$id]['value'], $this->t('A value is required if the label for this item is defined.'));
}
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.