function Name::validateExposed

Same name and namespace in other branches
  1. 9 core/modules/user/src/Plugin/views/filter/Name.php \Drupal\user\Plugin\views\filter\Name::validateExposed()
  2. 8.9.x core/modules/user/src/Plugin/views/filter/Name.php \Drupal\user\Plugin\views\filter\Name::validateExposed()
  3. 10 core/modules/user/src/Plugin/views/filter/Name.php \Drupal\user\Plugin\views\filter\Name::validateExposed()

Validate the exposed handler form.

Parameters

array $form: An alterable, associative array containing the structure of the form, passed by reference.

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

Overrides HandlerBase::validateExposed

File

core/modules/user/src/Plugin/views/filter/Name.php, line 88

Class

Name
Filter handler for usernames.

Namespace

Drupal\user\Plugin\views\filter

Code

public function validateExposed(&$form, FormStateInterface $form_state) {
  if (empty($this->options['exposed'])) {
    return;
  }
  if (empty($this->options['expose']['identifier'])) {
    return;
  }
  $identifier = $this->options['expose']['identifier'];
  $input = $form_state->getValue($identifier);
  if ($this->options['is_grouped'] && isset($this->options['group_info']['group_items'][$input])) {
    $this->operator = $this->options['group_info']['group_items'][$input]['operator'];
    $input = $this->options['group_info']['group_items'][$input]['value'];
  }
  $uids = [];
  $values = $form_state->getValue($identifier);
  if ($values && (!$this->options['is_grouped'] || $this->options['is_grouped'] && $input != 'All')) {
    foreach ($values as $value) {
      $uids[] = $value['target_id'];
    }
  }
  if ($uids) {
    $this->validated_exposed_input = $uids;
  }
}

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