How can I limit the days returned in the date module to today's and future dates only? I have the Date module installed on Drupal 7 (version 7.x-2.5) and I am attempting to disable the selection of past dates within the date popup.

$form['ratesDateSelect'] = array(
    '#title' =&gt; 'Arrival Date',
    '#type' =&gt; 'date_popup',
    '#default_value' =&gt; '',
    '#size' =&gt; 21,
    '#maxlength' =&gt; 100,
    '#date_flexible' =&gt; 0,
    '#date_year_range' =&gt; (date('Y')) . ':+5',
    '#attributes' =&gt; array('autocomplete' =&gt;'off','readonly' =&gt; 'readonly'),
    '#description' =&gt; '',
    '#value' =&gt; array('date' =&gt; $date),
    '#date_format' =&gt; 'D d M Y',
    '#required' =&gt; FALSE,
);


I have limited the popup to return this year and five years into the future, but I also need to restrict it so that people cannot select past days.

I have managed to do this in another project using pure javascript, using the datepicker param: minDate: 0
I worked this out shortly after posting, but it required a little bit of "hacking" of the date module.

To get this working I added a new '#settings' variable onto the date_popup type so it would look like .. 

$form['ratesDateSelect'] = array(
'#title' =&gt; 'Arrival Date',
'#type' =&gt; 'date_popup',
'#default_value' =&gt; '',
'#size' =&gt; 21,
'#maxlength' =&gt; 100,
'#date_flexible' =&gt; 0,
'#date_year_range' =&gt; (date('Y')) . ':+5',
'#attributes' =&gt; array('autocomplete' =&gt;'off','readonly' =&gt; 'readonly'),
'#description' =&gt; '',
'#value' =&gt; array('date' =&gt; $date),
'#date_format' =&gt; 'D d M Y',
'#required' =&gt; FALSE,
'#settings' =&gt; array('minDate'=&gt;'0'),
);


on the form element and then I added this code into date_popup.module (around line 336) after the settings array.

$user_settings = $element['#settings'];
foreach($user_settings as $setting_key =&gt; $setting_val) {
    $settings[$setting_key] = $setting_val;
}


This allowed me to inject javascript settings/options so that I can restrict the dates returned from now into the future.

Ryan