You are here

function _panopoly_search_form_validate in Panopoly Search 8.2

Validation callback for views_exposed_form() for our search views.

1 string reference to '_panopoly_search_form_validate'
panopoly_search_form_views_exposed_form_alter in ./panopoly_search.module
Implements hook_form_FORM_ID_alter().

File

./panopoly_search.module, line 114
Hooks for the panopoly_search module.

Code

function _panopoly_search_form_validate($form, FormStateInterface $form_state) {

  // Don't do anything if 'keys' isn't specified at all.
  $input = $form_state
    ->getUserInput();
  if ($input['keys'] === NULL) {
    return;
  }

  // Show error if 'keys' is specified, but empty.
  $keys = trim($form_state
    ->getValue('keys'));
  if (empty($keys)) {
    $form_state
      ->setErrorByName('keys', t('Please enter some keywords.'));
  }
}