public function SearchApiPageForm::validateForm in Search API Pages 8
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
- src/
Form/ SearchApiPageForm.php, line 245
Class
- SearchApiPageForm
- Class SearchApiPageForm.
Namespace
Drupal\search_api_page\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$path = $form_state
->getValue('path');
if (!empty($path)) {
$leading_slash = $path[0] === '/';
$trailing_slash = $path[strlen($path) - 1] === '/';
if ($leading_slash || $trailing_slash) {
$form_state
->setErrorByName('path', $this
->t('The path should not contain leading or trailing slashes.'));
}
}
}