public function PersistentLoginSettingsForm::validateForm in Persistent Login 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/ PersistentLoginSettingsForm.php, line 77
Class
- PersistentLoginSettingsForm
- Form for editing Persistent Login module settings.
Namespace
Drupal\persistent_login\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
if (!preg_match('/^[-_a-z0-9]+$/i', $form_state
->getValue('cookie_prefix'))) {
$form_state
->setErrorByName('cookie_prefix', $this
->t('Invalid characters in cookie prefix'));
}
elseif (preg_match('/^S?SESS$/', $form_state
->getValue('cookie_prefix'))) {
$form_state
->setErrorByName('cookie_prefix', $this
->t('Cookie prefix cannot be "SESS" because it is used by the Drupal session cookie.'));
}
}