You are here

public function FrontPageSettingsForm::validateForm in Front Page 8

Same name and namespace in other branches
  1. 9.1.x src/Form/FrontPageSettingsForm.php \Drupal\front_page\Form\FrontPageSettingsForm::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/FrontPageSettingsForm.php, line 94

Class

FrontPageSettingsForm
Configure site information settings for this site.

Namespace

Drupal\front_page\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {

  // parent::validateForm($form, $form_state);.
  $rolesList = $form_state
    ->getUserInput()['roles'];
  if ($rolesList) {
    foreach ($rolesList as $rid => $role) {
      if (!empty($role['enabled']) && empty($role['path'])) {
        $form_state
          ->setErrorByName('roles][' . $rid . '][path', $this
          ->t('You must set the path field for redirect mode.'));
      }
    }
  }
}