5

I have a custom module and using date_popup. Currently the popup only shows a 3 year range in the date popup.

  $form['startdate'] = array(
    '#type'       =>  'date_popup',
    '#title'      =>  'From',
    '#default_value'  =>  filter_get('browse-startdate'),
    '#date_format'    =>  'Y-m-d',
  );

What is needed to make the range higher?

2 Answers 2

6

Use the following option in the array:

    '#date_year_range' => '-8:+8'

That goes up to 8 years or more. Generally you don't use minDate as that only goes back up to 3 years only.

0

If it doesn't work backend wise like in my case (embedding user_register_form with date fields inside a custom build multistep form), you can alter these settings in javascript :

var fixDatepickerYearRange = function() {
        $('.field-widget-date-popup').find("input").datepicker({
          yearRange: "-100:+0",
          changeMonth: true,
          changeYear: true,
          dateFormat: "dd/mm/yy"
        });
      };

Just run it from document.load or Drupal.behaviors. More info : http://api.jqueryui.com/datepicker/#option-yearRange

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.