function TaxonomyIndexTid::valueValidate

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

Class

TaxonomyIndexTid
Filter by term id.

Namespace

Drupal\taxonomy\Plugin\views\filter

Code

protected function valueValidate($form, FormStateInterface $form_state) {
  // We only validate if they've chosen the text field style.
  if ($this->options['type'] != 'textfield') {
    return;
  }
  $tids = [];
  if ($values = $form_state->getValue([
    'options',
    'value',
  ])) {
    foreach ($values as $value) {
      $tids[] = $value['target_id'];
    }
  }
  $form_state->setValue([
    'options',
    'value',
  ], $tids);
}

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