You are here

function appointment_calendar_submit in Appointment Calendar 8

Implements submit function for appointment calendar submit.

1 string reference to 'appointment_calendar_submit'
appointment_calendar_form_alter in ./appointment_calendar.module
implements hook_form_alter().

File

./appointment_calendar.module, line 136

Code

function appointment_calendar_submit(array &$form, FormStateInterface $form_state) {
  $db_conn = \Drupal::database();

  // Form state Values.
  $values = $form_state
    ->getValues();
  $uid = $values['uid'][0]['target_id'];
  $nid = $values['nid'];
  $appointment_slot = $values['field_appointment_slot'];
  $appointment_date = strtotime(date('Y-m-d', $values['field_appointment_date'][0]['value']
    ->getTimestamp()));
  $db_conn
    ->merge('appointment_slots')
    ->key([
    'date' => $appointment_date,
    'nid' => $nid,
  ])
    ->fields([
    'slot' => $appointment_slot,
    'uid' => $uid,
  ])
    ->execute();
}