You are here

public function AppointmentCalendarListForm::validateForm in Appointment Calendar 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/AppointmentCalendarListForm.php, line 109

Class

AppointmentCalendarListForm

Namespace

Drupal\appointment_calendar\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  $op = (string) $values['op'];
  if ($op == $this
    ->t('Filter')) {
    $filter_date = $values['filter_date']
      ->getTimestamp();
    $filter_to_date = $values['filter_to_date']
      ->getTimestamp();
    if ($filter_date > $filter_to_date) {
      $form_state
        ->setErrorByName('filter_date', $this
        ->t('From Date is greater than "TO" date'));
    }
  }
}