You are here

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

Alters for the 'views_form_booking_cart_form_*' form.

1 call to rooms_booking_manager_views_form_booking_cart_form_()
rooms_booking_manager_form_alter in modules/rooms_booking_manager/rooms_booking_manager.module
Implements hook_form_alter().

File

modules/rooms_booking_manager/rooms_booking_manager.module, line 2434
Rooms Booking Manager brings together all the pieces required to find a room and book it - including the DrupalCommerce integration

Code

function rooms_booking_manager_views_form_booking_cart_form_(&$form, &$form_state, $form_id) {
  unset($form['actions']['submit']);
  $form['#action'] = str_replace('cart', 'bookings', $form['#action']);

  // Change any Delete buttons to say Remove.
  if (!empty($form['edit_delete'])) {
    foreach (element_children($form['edit_delete']) as $key) {

      // Load and wrap the line item to have the title in the submit phase.
      if (!empty($form['edit_delete'][$key]['#line_item_id'])) {
        $line_item_id = $form['edit_delete'][$key]['#line_item_id'];
        $form_state['line_items'][$line_item_id] = commerce_line_item_load($line_item_id);
        $form['edit_delete'][$key]['#value'] = variable_get_value('rooms_booking_manager_button_remove');
        $form['edit_delete'][$key]['#submit'] = array_merge($form['#submit'], array(
          'commerce_cart_line_item_delete_form_submit',
        ));
      }
    }
  }
  $form['actions']['checkout'] = array(
    '#type' => 'submit',
    '#value' => variable_get_value('rooms_booking_manager_button_checkout'),
    '#weight' => 5,
    '#access' => user_access('access checkout'),
    '#submit' => array_merge($form['#submit'], array(
      'commerce_checkout_line_item_views_form_submit',
    )),
  );
}