public function SearchPageFormBase::validateForm in Drupal 9
Same name and namespace in other branches
- 8 core/modules/search/src/Form/SearchPageFormBase.php \Drupal\search\Form\SearchPageFormBase::validateForm()
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 131
Class
- SearchPageFormBase
- Provides a base form for search pages.
Namespace
Drupal\search\FormCode
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);
}
}