You are here

function merci_hours_form_submit in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3

Form API submit callback for the save button.

See also

merci_hours_form().

File

merci_hours/includes/entity.ui.inc, line 68
Work calendar editing UI.

Code

function merci_hours_form_submit($form, &$form_state) {
  $merci_hours = entity_ui_form_submit_build_entity($form, $form_state);

  // TODO a bit hacky.
  $items = array();
  foreach ($merci_hours->field_office_hours['und'] as $delta => $data) {
    if (!$data['remove_hours']) {
      $items[] = $data;
    }
  }
  $merci_hours->field_office_hours['und'] = $items;

  // Update availability before save.

  //$merci_hours->updateWeek($form_state['values']['week_days']);

  // Save and go back.
  $merci_hours
    ->save();
  $form_state['redirect'] = 'admin/merci/config/merci-hours';
}