I am trying to set up a content review process for a client's site.

The desired process is this:

  • When users are adding content, they specify a "review date"
    • This date must be between today and today +365 days
    • A week before that date, send an email to users of a role letting them know

When I am setting up the date field, I've set "Starting year" and "Ending year" (in Field Settings -> More settings and values -> Date entry), however this doesn't behave as expected. It will let you set a date within calendar years, but not within a year of today. So I can make it work for any date in 2012, but not a specific day.

I'm fine with the rules + email bit, just the date field is holding me up.

I'm thinking it will be some custom JS, but am open to any approaches :-)

1 Answer 1


Ok, so this is our "solution". Not tidy, but we didn't want to edit the date module directly.

My module:

function modulename_form_alter(&$form, &$form_state, $form_id){  
  if(substr($form_id,-9) !== "node_form" ){
$jsPath = drupal_get_path('module', 'modulename');
  $jsOptions = array(
    'group' => JS_THEME,
    'weight' => 20
  // Load this JS late, so that it happens after the main date module   
  drupal_add_js("$jsPath/js/modulename_datepicker.js", $jsOptions);

My colleagues code for the modulename_datepicker.js file:

    for (var id in Drupal.settings.datePopup) { 
        if (Drupal.settings.datePopup[id].func == "datepicker") {
            var defVal = jQuery('#'+id).val();

            jQuery('#'+id).datepicker( "option" , {
                changeMonth: Drupal.settings.datePopup[id].settings.changeMonth,
                changeYear: Drupal.settings.datePopup[id].settings.changeYear,
                firstDay: Drupal.settings.datePopup[id].settings.firstDay,
                defaultDate: Drupal.settings.datePopup[id].settings.defaultDate,
                dateFormat: Drupal.settings.datePopup[id].settings.dateFormat,
                minDate: 0, 
                maxDate: "+1Y"

            if (defVal == '') {
                jQuery('#'+id).datepicker( "setDate" , "+1Y");
            } else {
                jQuery('#'+id).datepicker( "setDate" , defVal);


Better solutions welcomed :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.