You are here

public function TaxonomyIndexMachineName::validateExposed in Taxonomy Machine Name 8

Validate the exposed handler form

Overrides HandlerBase::validateExposed

File

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

Class

TaxonomyIndexMachineName
Filter by term id.

Namespace

Drupal\taxonomy_machine_name\Plugin\views\filter

Code

public function validateExposed(&$form, FormStateInterface $form_state) {
  if (empty($this->options['exposed'])) {
    return;
  }
  $identifier = $this->options['expose']['identifier'];

  // We only validate if they've chosen the text field style.
  if ($this->options['type'] != 'textfield') {
    if ($form_state
      ->getValue($identifier) != 'All') {
      $this->validatedExposedInput = (array) $form_state
        ->getValue($identifier);
    }
    return;
  }
  if (empty($this->options['expose']['identifier'])) {
    return;
  }
  if ($values = $form_state
    ->getValue($identifier)) {
    foreach ($values as $value) {
      $this->validatedExposedInput[] = $value['target_id'];
    }
  }
}