0

I am looking for a way to remove the select drop-downs from the datepicker popup and display only months (and the year). As for the appearance, it can be altered in datepicker.1.7.css.

How do I disable the select drop-downs and show only the names?

4
  • In short, you want to remove days from the date & you want to display only month & year. Am I right ?
    – Nishant
    Dec 11, 2014 at 11:30
  • Hey. Not quite. In short: Remove dropdowns and only display month-name and year. User navigates only via arrows. Dec 11, 2014 at 11:34
  • Check this first : stackoverflow.com/questions/5229654/…
    – Nishant
    Dec 11, 2014 at 11:48
  • Unfortunately this does not show, how to hide the select-fields and use an alternative display instead. But it definitely points me to the right files! Dec 11, 2014 at 12:02

2 Answers 2

1

As of date_popup 7.x-2.9, you can do this in your theme or custom module, implementing hook_element_info_alter(&$type).

function mytheme_element_info_alter(&$type) {
  $type['date_popup']['#datepicker_options'] += array(
    'changeMonth' => FALSE,
    'changeYear' => FALSE,
  );
}
-1

Did it. Turns out, that you can influence the datepicker options in modules/date/data_popup/date_popup.module. In the function date_popup_element_info you can influence the datepicker-options for the jquery-part. This means that:

'#datepicker_options' => array(
  'changeMonth' => FALSE,
  'changeYear' => FALSE
),

will disable the dropdowns. However remember: This is a system wide change and might be gone with the next update.

1
  • 1
    You'd be much better changing the form using hook_form_alter as hacking contributed module code is, as you point out, a recipe for disaster over time.
    – bloke_zero
    Dec 12, 2014 at 9:40

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.