protected function Date::buildGroupValidate in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/src/Plugin/views/filter/Date.php \Drupal\views\Plugin\views\filter\Date::buildGroupValidate()
Validate the build group options form.
Overrides FilterPluginBase::buildGroupValidate
File
- core/
modules/ views/ src/ Plugin/ views/ filter/ Date.php, line 108 - Contains \Drupal\views\Plugin\views\filter\Date.
Class
- Date
- Filter to handle dates stored as a timestamp.
Namespace
Drupal\views\Plugin\views\filterCode
protected function buildGroupValidate($form, FormStateInterface $form_state) {
// Special case to validate grouped date filters, this is because the
// $group['value'] array contains the type of filter (date or offset)
// and therefore the number of items the comparison has to be done
// against 'one' instead of 'zero'.
foreach ($form_state
->getValue(array(
'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']) && empty($group['value']) || is_array($group['value']) && count(array_filter($group['value'])) == 1) {
$form_state
->setError($form['group_info']['group_items'][$id]['value'], $this
->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']) && !empty($group['value']) || is_array($group['value']) && count(array_filter($group['value'])) > 1) {
if (empty($group['title'])) {
$form_state
->setError($form['group_info']['group_items'][$id]['title'], $this
->t('The title is required if value for this item is defined.'));
}
}
}
}
}