You are here

public function RegcodeAdminCreateForm::validateForm in Registration codes 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/RegcodeAdminCreateForm.php, line 122

Class

RegcodeAdminCreateForm
Form for creation of registration codes.

Namespace

Drupal\regcode\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  if (!is_numeric($form_state
    ->getValue([
    'regcode_create_maxuses',
  ])) || $form_state
    ->getValue([
    'regcode_create_maxuses',
  ]) < 0) {
    $form_state
      ->setErrorByName('regcode_create_maxuses', $this
      ->t('Invalid maxuses, specify a positive integer or enter "0" for unlimited'));
  }
}