function _rooms_select_rooms_validation in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7
Helper validate function to ensure that at least one room is selected.
2 calls to _rooms_select_rooms_validation()
- rooms_availability_update_status_form_validate in modules/
rooms_availability/ rooms_availability.module - Validate callback for rooms_availability_update_status_form form.
- rooms_pricing_update_form_validate in modules/
rooms_pricing/ rooms_pricing.module - Validate callback for rooms_pricing_update_form form.
File
- ./
rooms.module, line 1158 - Provides basic underlying functionality and configuration options used by all Rooms modules
Code
function _rooms_select_rooms_validation($form_state) {
$select_rooms = FALSE;
if ($form_state['values']['select-all'] == ROOMS_ALL_PAGES || $form_state['values']['select-all'] == ROOMS_THIS_PAGE) {
$select_rooms = TRUE;
}
else {
foreach ($form_state['values'] as $key => $value) {
if (strpos($key, 'rooms-') === 0 && $value == '1') {
$select_rooms = TRUE;
}
}
}
if (!$select_rooms) {
form_set_error('select-all', t('You have to select at least one unit to update.'));
}
}