1 views_handler_filter_search.inc views_handler_filter_search::exposed_validate(&$form, &$form_state)

Validate the options form.

Overrides views_handler::exposed_validate

File

core/modules/search/views/views_handler_filter_search.inc, line 84
Contains a search filter handler.

Class

views_handler_filter_search
Field handler to provide simple renderer that allows linking to a node.

Code

function exposed_validate(&$form, &$form_state) {
  if (!isset($this->options['expose']['identifier'])) {
    return;
  }

  $key = $this->options['expose']['identifier'];
  // No search terms.
  if (empty($form_state['values'][$key])) {
    // The 'optional' property means: show all items if no input is set,
    // 'required' means that no results should be shown if there's no input.
    // @see views_handler_filter_search::operator_form()
    if ($this->operator != 'optional' && empty($this->options['expose']['required'])) {
      $this->view->built = TRUE;
      $this->view->executed = TRUE;
      $this->view->result = array();
      return;
    }
  }
  if (!empty($form_state['values'][$key])) {
    $this->query_parse_search_expression($form_state['values'][$key]);
    if (count($this->search_query->words()) == 0) {
      form_set_error($key, format_plural(config_get('search.settings', 'search_minimum_word_size'), 'You must include at least one positive keyword with 1 character or more.', 'You must include at least one positive keyword with @count characters or more.'));
    }
  }
}