function SearchPageFormBase::validateForm

Same name in other branches
  1. 8.9.x core/modules/search/src/Form/SearchPageFormBase.php \Drupal\search\Form\SearchPageFormBase::validateForm()
  2. 10 core/modules/search/src/Form/SearchPageFormBase.php \Drupal\search\Form\SearchPageFormBase::validateForm()
  3. 11.x core/modules/search/src/Form/SearchPageFormBase.php \Drupal\search\Form\SearchPageFormBase::validateForm()

Overrides FormBase::validateForm

File

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

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->entityTypeManager
        ->getStorage('search_page')
        ->getQuery()
        ->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);
    }
}

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