Thanx for a fantastic module!
Regarding the seach box, isn´t there any possible way to get a calender popup on check out date.
I whant my ta pick a checkin date, and a checkout date.

The project I am working on have rooms that is rented for sometimes moths at the time.
And its difficult to have that under Nights.

I know that the module is developed for simple hotel bookings.
But wouldnt this be useful even for that...?

Anyone who can help me to answer how to do this modification?

Best regards


larowlan’s picture

If you're php savvy you can create a new module with the following function. If you're not sure on how to create a module, use the modulebuilder module. This code is untested (other than php validation) but should be near to working order. Replace the MYMODULE with your module name.

 * Implementation of hook_form_alter
function MYMODULE_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'hotel_booking_widget_form') {
    $form['roomsearch']['checkout'] = array(
      '#prefix' => '<div class="bking-date">',
      '#type' => 'date_popup',
      '#title' => 'Check-Out Date',
      '#required' => TRUE,
      '#size' => 14,
      '#date_type' => DATE_ISO,
      '#date_timezone' => date_default_timezone_name(),
      '#date_format' => 'm/d/Y',
      '#date_year_range' => '-0:+1',
      '#suffix' => '</div>',
     if (isset($form['#validate']) && is_array($form['#validate'])) {
      array_unshift($form['#validate'], 'MYMODULE_validate_checkout');
    else {
      $form['#validate'] = array('MYMODULE_validate_checkout');

 * Validation to switch the checkout back to staylength
function MYMODULE_validate_checkout($form, &$form_state) {
    $nights = (strtotime($form_state['values']['checkout']) - strtotime($form_state['values']['checkin']))/ 86400; //86400 secs in day
   $form_state['values']['staylength'] = $nights;
Mr J’s picture

Status: Active » Fixed

Works Perfect!
Thanx larowlan!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

gamini2006’s picture

Status: Closed (fixed) » Active

Dear larowlan/Mr J

I have the same requirement. I tried as larowlan post, but it didn't work for me. Please help me with more details.
I created a module and add the given code, activated the module, but it didn't work. Pleae help

ccc7919’s picture

Version: 6.x-1.0-beta3 » 7.x-1.0-beta1