You are here

public function AppointmentCalendarListForm::submitForm in Appointment Calendar 8

Form submission 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 FormInterface::submitForm

File

src/Form/AppointmentCalendarListForm.php, line 124

Class

AppointmentCalendarListForm

Namespace

Drupal\appointment_calendar\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  $op = (string) $values['op'];

  // Goto current path if reset.
  if ($op == $this
    ->t('Reset')) {
    $form_state
      ->setRedirect('appointment_calendar.list_page');
  }

  // Pass values to url.
  if ($op == $this
    ->t('Filter')) {
    $filter_date = $values['filter_date']
      ->getTimestamp();
    $filter_to_date = $values['filter_to_date']
      ->getTimestamp();
    $params['date'] = Html::escape($filter_date);
    $params['todate'] = Html::escape($filter_to_date);
    $form_state
      ->setRedirect('appointment_calendar.list_page', [
      $params,
    ]);
  }
}