You are here

public function SettingsForm::validateForm in Christmas Lights 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/SettingsForm.php, line 60

Class

SettingsForm
Defines a form that configures christmas_lights settings.

Namespace

Drupal\christmas_lights\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  $start = strtotime($values['start']);
  $end = strtotime($values['end']);
  if ($start >= $end) {
    $form_state
      ->setErrorByName('start', $this
      ->t('You must select a valid start date.'));
  }
}