You are here

protected function TaxonomyIndexMachineName::valueValidate in Taxonomy Machine Name 8

Validate the options form.

Overrides FilterPluginBase::valueValidate

File

src/Plugin/views/filter/TaxonomyIndexMachineName.php, line 283

Class

TaxonomyIndexMachineName
Filter by term id.

Namespace

Drupal\taxonomy_machine_name\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);
}