function BooleanOperator::valueValidate

Same name and namespace in other branches
  1. 9 core/modules/views/src/Plugin/views/filter/BooleanOperator.php \Drupal\views\Plugin\views\filter\BooleanOperator::valueValidate()
  2. 8.9.x 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()

Validate the options form.

Parameters

array $form: Associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FilterPluginBase::valueValidate

File

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

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.