You are here

public function AdminSettingsForm::validateForm in Role Based Theme Switcher 8

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

Class

AdminSettingsForm
Configure Role Based settings for this site.

Namespace

Drupal\role_based_theme_switcher\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $rollTheme = $form_state
    ->getValue('role_theme');
  $role_arr = [];
  foreach ($rollTheme as $key => $value) {
    if (in_array((int) $value['weight'], $role_arr)) {
      $form_state
        ->setErrorByName('role_theme', $this
        ->t("There are errors in the form"));
    }
    $role_arr[$key] = (int) $value['weight'];
  }
}