public function PageSpecificClassSettingsForm::validateForm in Page Specific Class 2.0.x
Same name and namespace in other branches
- 8 src/Form/PageSpecificClassSettingsForm.php \Drupal\page_specific_class\Form\PageSpecificClassSettingsForm::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
- src/
Form/ PageSpecificClassSettingsForm.php, line 57
Class
- PageSpecificClassSettingsForm
- Configure custom settings for Page Specific Class.
Namespace
Drupal\page_specific_class\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$url_with_class = $form_state
->getValue('url_with_class');
if (!empty($url_with_class)) {
$enteredArr = explode(PHP_EOL, $url_with_class);
foreach ($enteredArr as $values) {
$urlWithClassArr = explode("|", $values);
$url = $urlWithClassArr[0];
if ($url[0] !== '/') {
$form_state
->setErrorByName('url_with_class', $this
->t("@url path needs to start with a slash.", [
'@url' => $url,
]));
}
}
}
}