You are here

public function EditForm::validateForm in bootstrap simple carousel 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/EditForm.php, line 186

Class

EditForm
Class EditForm.

Namespace

Drupal\bootstrap_simple_carousel\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  if (!in_array($form_state
    ->getValue('status'), [
    0,
    1,
  ])) {
    $form_state
      ->setErrorByName('status', $this
      ->t('Status is incorrect.'));
  }
  if ($form_state
    ->getValue('weight') < 0) {
    $form_state
      ->setErrorByName('status', $this
      ->t('Weight must be zero or greater than zero.'));
  }
}