public function LoginRedirectionForm::validateForm in Redirect after 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/ LoginRedirectionForm.php, line 61 - Contains \Drupal\redirect_after_login\Form\LoginRedirectionForm.
Class
Namespace
Drupal\redirect_after_login\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
foreach ($this->allUser as $user => $name) {
if (!(preg_match('/^[#?\\/]+/', $form_state
->getValue($user)) || $form_state
->getValue($user) == '<front>')) {
$form_state
->setErrorByName($user, t('This URL %url is not valid for role %role.', array(
'%url' => $form_state
->getValue($user),
'%role' => $name,
)));
}
}
}