function FilterPluginBase::build_group_validate in Views (for Drupal 7) 8.3
Validate the build group options form.
1 call to FilterPluginBase::build_group_validate()
- FilterPluginBase::validateOptionsForm in lib/
Drupal/ views/ Plugin/ views/ filter/ FilterPluginBase.php - Simple validate handler
1 method overrides FilterPluginBase::build_group_validate()
- Date::build_group_validate in lib/
Drupal/ views/ Plugin/ views/ filter/ Date.php - Validate the build group options form.
File
- lib/
Drupal/ views/ Plugin/ views/ filter/ FilterPluginBase.php, line 595 - Definition of Drupal\views\Plugin\views\filter\FilterPluginBase.
Class
- FilterPluginBase
- Base class for filters.
Namespace
Drupal\views\Plugin\views\filterCode
function build_group_validate($form, &$form_state) {
if (!empty($form_state['values']['options']['group_info'])) {
if (empty($form_state['values']['options']['group_info']['identifier'])) {
form_error($form['group_info']['identifier'], t('The identifier is required if the filter is exposed.'));
}
if (!empty($form_state['values']['options']['group_info']['identifier']) && $form_state['values']['options']['group_info']['identifier'] == 'value') {
form_error($form['group_info']['identifier'], t('This identifier is not allowed.'));
}
if (!$this->view->display_handler
->isIdentifierUnique($form_state['id'], $form_state['values']['options']['group_info']['identifier'])) {
form_error($form['group_info']['identifier'], t('This identifier is used by another handler.'));
}
}
if (!empty($form_state['values']['options']['group_info']['group_items'])) {
foreach ($form_state['values']['options']['group_info']['group_items'] as $id => $group) {
if (empty($group['remove'])) {
// Check if the title is defined but value wasn't defined.
if (!empty($group['title'])) {
if (!is_array($group['value']) && trim($group['value']) == "" || is_array($group['value']) && count(array_filter($group['value'], '_views_array_filter_zero')) == 0) {
form_error($form['group_info']['group_items'][$id]['value'], t('The value is required if title for this item is defined.'));
}
}
// Check if the value is defined but title wasn't defined.
if (!is_array($group['value']) && trim($group['value']) != "" || is_array($group['value']) && count(array_filter($group['value'], '_views_array_filter_zero')) > 0) {
if (empty($group['title'])) {
form_error($form['group_info']['group_items'][$id]['title'], t('The title is required if value for this item is defined.'));
}
}
}
}
}
}