function _rooms_booking_manager_add_options in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7
Checks if there are any options to add to units and loads them if so.
Parameters
$form:
$type:
$price:
$c:
$option:
Return value
mixed
1 call to _rooms_booking_manager_add_options()
- book_units_per_type_form in modules/
rooms_booking_manager/ rooms_booking_manager.module - Book units per type booking form callback.
File
- modules/
rooms_booking_manager/ rooms_booking_manager.units_per_type_form.inc, line 221 - Helper functions to clear up the units per type form and make the logic easier to follow.
Code
function _rooms_booking_manager_add_options($form, $form_state, $type, $price, $c, $option) {
$option_name = rooms_options_machine_name($option['name']);
$form[$type][$price]['fieldset'][$c][$option_name] = array(
'#type' => 'checkbox',
'#title' => t($option['name']),
'#ajax' => array(
'callback' => 'rooms_booking_manager_options_change_callback',
'wrapper' => $type . '_' . $price . '_' . $c . '_price',
),
);
if ($option['type'] == ROOMS_OPTION_MANDATORY) {
$form[$type][$price]['fieldset'][$c][$option_name]['#default_value'] = '1';
$form[$type][$price]['fieldset'][$c][$option_name]['#disabled'] = TRUE;
}
elseif ($option['type'] == ROOMS_OPTION_ONREQUEST) {
$form[$type][$price]['fieldset'][$c][$option_name]['#title'] .= ' - ' . variable_get_value('rooms_booking_manager_onrequest_option');
}
// Show quantity field selector if an option quantity is set.
if (is_numeric($option['quantity'])) {
if ((isset($form_state['values'][$type][$price]['fieldset'][$c][$option_name]) && $form_state['values'][$type][$price]['fieldset'][$c][$option_name] == 1 || $option['type'] == ROOMS_OPTION_MANDATORY) && $option['quantity'] > 1) {
$form[$type][$price]['fieldset'][$c][$option_name . ':quantity'] = array(
'#type' => 'select',
'#title' => t('Quantity'),
'#options' => range(1, $option['quantity']),
'#ajax' => array(
'callback' => 'rooms_booking_manager_options_change_callback',
'wrapper' => $type . '_' . $price . '_' . $c . '_price',
),
'#prefix' => '<div class="rooms-search-result__select-quantity" id="' . $type . '_' . $price . '_' . $c . '_' . $option_name . '_quantity">',
'#suffix' => '</div>',
);
}
else {
$form[$type][$price]['fieldset'][$c][$option_name . ':quantity'] = array(
'#prefix' => '<div class="rooms-search-result__select-quantity" id="' . $type . '_' . $price . '_' . $c . '_' . $option_name . '_quantity">',
'#suffix' => '</div>',
);
}
}
return $form;
}