function BooleanOperator::valueValidate

Same name in other branches
  1. 8.9.x core/modules/views/src/Plugin/views/filter/BooleanOperator.php \Drupal\views\Plugin\views\filter\BooleanOperator::valueValidate()
  2. 10 core/modules/views/src/Plugin/views/filter/BooleanOperator.php \Drupal\views\Plugin\views\filter\BooleanOperator::valueValidate()
  3. 11.x core/modules/views/src/Plugin/views/filter/BooleanOperator.php \Drupal\views\Plugin\views\filter\BooleanOperator::valueValidate()

Overrides FilterPluginBase::valueValidate

File

core/modules/views/src/Plugin/views/filter/BooleanOperator.php, line 189

Class

BooleanOperator
Simple filter to handle matching of boolean values.

Namespace

Drupal\views\Plugin\views\filter

Code

protected function valueValidate($form, FormStateInterface $form_state) {
    if ($form_state->getValue([
        'options',
        'value',
    ]) == 'All' && !$form_state->isValueEmpty([
        'options',
        'expose',
        'required',
    ])) {
        $form_state->setErrorByName('value', $this->t('You must select a value unless this is an non-required exposed filter.'));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.