You are here

public function SettingsForm::validateForm in Session Limit 8

Same name and namespace in other branches
  1. 2.x src/Form/SettingsForm.php \Drupal\session_limit\Form\SettingsForm::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/SettingsForm.php, line 97

Class

SettingsForm

Namespace

Drupal\session_limit\Form

Code

public function validateForm(array &$form, \Drupal\Core\Form\FormStateInterface $form_state) {
  $maxsessions = $form_state
    ->getValue([
    'session_limit_max',
  ]);
  if (!is_numeric($maxsessions)) {
    $form_state
      ->setErrorByName('session_limit_max', $this
      ->t('You must enter a number for the maximum number of active sessions'));
  }
  elseif ($maxsessions < 0) {
    $form_state
      ->setErrorByName('session_limit_max', $this
      ->t('Maximum number of active sessions must be positive'));
  }
}