public function AlternativeFrontpageSettings::validateForm in Open Social 8
Same name and namespace in other branches
- 8.9 modules/custom/alternative_frontpage/src/Form/AlternativeFrontpageSettings.php \Drupal\alternative_frontpage\Form\AlternativeFrontpageSettings::validateForm()
- 8.2 modules/custom/alternative_frontpage/src/Form/AlternativeFrontpageSettings.php \Drupal\alternative_frontpage\Form\AlternativeFrontpageSettings::validateForm()
- 8.3 modules/custom/alternative_frontpage/src/Form/AlternativeFrontpageSettings.php \Drupal\alternative_frontpage\Form\AlternativeFrontpageSettings::validateForm()
- 8.4 modules/custom/alternative_frontpage/src/Form/AlternativeFrontpageSettings.php \Drupal\alternative_frontpage\Form\AlternativeFrontpageSettings::validateForm()
- 8.5 modules/custom/alternative_frontpage/src/Form/AlternativeFrontpageSettings.php \Drupal\alternative_frontpage\Form\AlternativeFrontpageSettings::validateForm()
- 8.6 modules/custom/alternative_frontpage/src/Form/AlternativeFrontpageSettings.php \Drupal\alternative_frontpage\Form\AlternativeFrontpageSettings::validateForm()
- 8.7 modules/custom/alternative_frontpage/src/Form/AlternativeFrontpageSettings.php \Drupal\alternative_frontpage\Form\AlternativeFrontpageSettings::validateForm()
- 8.8 modules/custom/alternative_frontpage/src/Form/AlternativeFrontpageSettings.php \Drupal\alternative_frontpage\Form\AlternativeFrontpageSettings::validateForm()
- 10.3.x modules/custom/alternative_frontpage/src/Form/AlternativeFrontpageSettings.php \Drupal\alternative_frontpage\Form\AlternativeFrontpageSettings::validateForm()
- 10.0.x modules/custom/alternative_frontpage/src/Form/AlternativeFrontpageSettings.php \Drupal\alternative_frontpage\Form\AlternativeFrontpageSettings::validateForm()
- 10.1.x modules/custom/alternative_frontpage/src/Form/AlternativeFrontpageSettings.php \Drupal\alternative_frontpage\Form\AlternativeFrontpageSettings::validateForm()
- 10.2.x modules/custom/alternative_frontpage/src/Form/AlternativeFrontpageSettings.php \Drupal\alternative_frontpage\Form\AlternativeFrontpageSettings::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
- modules/
custom/ alternative_frontpage/ src/ Form/ AlternativeFrontpageSettings.php, line 91
Class
- AlternativeFrontpageSettings
- Class AlternativeFrontpageSettings.
Namespace
Drupal\alternative_frontpage\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$frontpage_for_anonymous_user = $form_state
->getValue('frontpage_for_anonymous_users');
$frontpage_for_authenticated_user = $form_state
->getValue('frontpage_for_authenticated_user');
if ($frontpage_for_anonymous_user) {
if (!$this->pathValidator
->getUrlIfValidWithoutAccessCheck($frontpage_for_anonymous_user)) {
$form_state
->setErrorByName('frontpage_for_anonymous_users', $this
->t('The path for the anonymous frontpage is not valid.'));
}
elseif (substr($frontpage_for_anonymous_user, 0, 1) !== '/') {
$form_state
->setErrorByName('frontpage_for_anonymous_users', $this
->t('The path for the anonymous frontpage should start with a forward slash.'));
}
elseif (!$this
->isAllowedPath($frontpage_for_anonymous_user)) {
$form_state
->setErrorByName('frontpage_for_anonymous_users', $this
->t('The path for the anonymous frontpage is not allowed.'));
}
}
else {
$form_state
->setErrorByName('frontpage_for_anonymous_users', $this
->t('The path for the anonymous frontpage cannot be empty.'));
}
if ($frontpage_for_authenticated_user) {
if (!$this->pathValidator
->getUrlIfValidWithoutAccessCheck($frontpage_for_authenticated_user)) {
$form_state
->setErrorByName('frontpage_for_authenticated_user', $this
->t('The path for the authenticated frontpage is not valid.'));
}
elseif (substr($frontpage_for_authenticated_user, 0, 1) !== '/') {
$form_state
->setErrorByName('frontpage_for_authenticated_user', $this
->t('The path for the authenticated frontpage should start with a forward slash.'));
}
elseif (!$this
->isAllowedPath($frontpage_for_authenticated_user)) {
$form_state
->setErrorByName('frontpage_for_authenticated_user', $this
->t('The path for the authenticated frontpage is not allowed.'));
}
}
}