function TaxonomyIndexTid::valueValidate

Same name 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. 10 core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid::valueValidate()

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.