function FilterPluginBase::buildGroupValidate
Same name in other branches
- 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()
- 11.x 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 719
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'] == '') {
$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.