You are here

function rooms_unit_type_form_submit in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7

Form API submit callback for the type form.

File

modules/rooms_unit/rooms_unit_type.admin.inc, line 234
RoomsUnit type editing UI.

Code

function rooms_unit_type_form_submit($form, &$form_state) {
  $unit_type = entity_ui_form_submit_build_entity($form, $form_state);

  // Save and go back.
  $unit_type
    ->save();

  // Get all unit types to show in unit type selector.
  $unit_types = variable_get_value('rooms_unit_type_selector');

  // If checked add unit type to list of unit types to show.
  if (!empty($form_state['values']['unit_type_selector'])) {
    $unit_types[$form_state['values']['type']] = $form_state['values']['type'];
    variable_set('rooms_unit_type_selector', $unit_types);
  }
  else {
    if (isset($unit_types[$form_state['values']['type']])) {
      unset($unit_types[$form_state['values']['type']]);
      variable_set('rooms_unit_type_selector', $unit_types);
    }
  }
  $form_state['unit_type'] = $unit_type;
  $form_state['redirect'] = 'admin/rooms/units/unit-types';
}