You are here

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

Form API submit callback for the entity_type form.

@todo remove hard-coded link

1 string reference to 'merci_line_item_ui_form_submit'
merci_line_item_form in merci_line_item/merci_line_item_ui.pages.inc
Form callback: create or edit a entity_type.

File

merci_line_item/merci_line_item_ui.pages.inc, line 152

Code

function merci_line_item_ui_form_submit(&$form, &$form_state) {
  $entity_type = $form_state['entity_type'];
  $entity = entity_ui_controller($entity_type)
    ->entityFormSubmitBuildEntity($form, $form_state);
  $entity_info = $entity
    ->entityInfo();
  $path = $entity_info['admin ui']['path'];

  // Save the entity_type and go back to the list of entity_types
  // Add in created and changed times.
  if ($entity->is_new = isset($entity->is_new) ? $entity->is_new : 0) {
    $entity->created = time();
  }
  $entity->changed = time();
  $entity
    ->save();
  $type_url_str = str_replace('_', '-', $entity_type);
  $form_state['redirect'] = $path . '/' . $entity->line_item_id . '/edit';

  //'admin/content/' . $type_url_str;
  drupal_set_message(t('Line item saved.'));
}