SearchPageFormBase::validateForm

public SearchPageFormBase::validateForm(array &$form, FormStateInterface $form_state)

Form validation handler.

Parameters

array $form: An associative array containing the structure of the form.

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

Overrides FormBase::validateForm

File

core/modules/search/src/Form/SearchPageFormBase.php, line 143

Class

SearchPageFormBase
Provides a base form for search pages.

Namespace

Drupal\search\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);

  // Ensure each path is unique.
  $path = $this->entityQuery->get('search_page')
    ->condition('path', $form_state->getValue('path'))
    ->condition('id', $form_state->getValue('id'), '<>')
    ->execute();
  if ($path) {
    $form_state->setErrorByName('path', $this->t('The search page path must be unique.'));
  }

  if ($this->plugin instanceof PluginFormInterface) {
    $this->plugin->validateConfigurationForm($form, $form_state);
  }
}
doc_Drupal
2016-10-29 09:40:36
Comments
Leave a Comment

Please login to continue.