If you set a date to be for a previous year by default, the popup shows the correct year, but when you click a date, it gives the current year instead of a previous year.

  • Configure a content type with a date field.
  • Set the "Years back and forward" to be -13:-9
  • Configure the field widget to be "text field with date pop-up calendar"
  • Then create an element. The date popup will come up with a date in 1996, as it should.
  • Click a date, say July 15
  • The date in the text field will be July 15, 2009, not July 15, 1996.

Attached are an exported content type and a screenshot of the behavior. This was demonstrated with date-6.x-2.2 and a clean Drupal install.

Comments

mchaplin’s picture

I get this issue as well. Perhaps there's some validation that can pick up the current year and prevent a save?

arlinsandbulte’s picture

Version: 6.x-2.2 » 6.x-2.6

Issue confirmed in Date 6.x-2.6.

Issue seems to be in how the jquery UI popup is initialized.
The month grid is from the current year, even though the year select list is correct.

aron novak’s picture

Status: Active » Needs review

I have a patch for that, sorry for not providing a real patch, only this snippet:
in date_popup.module / date_popup_js_settings_id()

if (!empty($settings['yearRange'])) {
    $parts = explode(':', $settings['yearRange']);
    $settings += array('defaultDate' => (string) $parts[0] . 'y');
  }
rfay’s picture

Status: Needs review » Needs work

@Aron, please provide a patch. http://drupal.org/patch

arlinsandbulte’s picture

Version: 6.x-2.6 » 6.x-2.x-dev
Status: Needs work » Needs review
StatusFileSize
new857 bytes

Thanks for the code, Aron. I stuck it in and it seems to work after just a couple seconds of testing.

Attached is a patch file.
I added a comment, but I'm not sure if it describes it very well & I included this issue as a reference, which may not be standard drupal documentation practice.

[note to self] The D7 code in head appears identical to the D6 code, so if this goes in, it should also go into HEAD.

rfay’s picture

StatusFileSize
new1.21 KB

Works for me.

Attached is a reroll from the root of the project against current 6.x-2.x. It's the same thing. I took out the reference to this bug, as that doesn't end up too useful in the long run IMO.

Nice work on this!

arlinsandbulte’s picture

Component: Code » Date Popup
Status: Needs review » Fixed

Good enough for me...
Committed:
http://drupal.org/cvs?commit=427858

And against HEAD (D7 development):
http://drupal.org/cvs?commit=427868

Status: Fixed » Closed (fixed)

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