function Search::validateExposed

Same name in other branches
  1. 9 core/modules/search/src/Plugin/views/filter/Search.php \Drupal\search\Plugin\views\filter\Search::validateExposed()
  2. 10 core/modules/search/src/Plugin/views/filter/Search.php \Drupal\search\Plugin\views\filter\Search::validateExposed()
  3. 11.x core/modules/search/src/Plugin/views/filter/Search.php \Drupal\search\Plugin\views\filter\Search::validateExposed()

Overrides HandlerBase::validateExposed

File

core/modules/search/src/Plugin/views/filter/Search.php, line 101

Class

Search
Filter handler for search keywords.

Namespace

Drupal\search\Plugin\views\filter

Code

public function validateExposed(&$form, FormStateInterface $form_state) {
    if (!isset($this->options['expose']['identifier'])) {
        return;
    }
    $key = $this->options['expose']['identifier'];
    if (!$form_state->isValueEmpty($key)) {
        $this->queryParseSearchExpression($form_state->getValue($key));
        if (count($this->searchQuery
            ->words()) == 0) {
            $form_state->setErrorByName($key, $this->formatPlural(\Drupal::config('search.settings')->get('index.minimum_word_size'), 'You must include at least one keyword to match in the content, and punctuation is ignored.', 'You must include at least one keyword to match in the content. Keywords must be at least @count characters, and punctuation is ignored.'));
        }
    }
}

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