You are here

public function AppointmentCalendarDeleteForm::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/AppointmentCalendarDeleteForm.php, line 76

Class

AppointmentCalendarDeleteForm

Namespace

Drupal\appointment_calendar\Form

Code

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

  // Delete Slot.
  if ($op == $this
    ->t('Yes')) {
    $db_conn
      ->delete('appointment_date')
      ->condition('date', $values['date'])
      ->execute();
    $this
      ->messenger()
      ->addStatus(t('Selected Date deleted successfully'));
    $form_state
      ->setRedirect('appointment_calendar.list_page');
  }

  // Go-to Listing Page.
  if ($op == $this
    ->t('No') || $op == $this
    ->t('Return')) {
    $form_state
      ->setRedirect('appointment_calendar.list_page');
  }
}