We've just upgraded Webform from 7.x-4.7 to 7.x-4.2 and one of the changes made to the date component changes the behaviour of the year select box.

We have always used the start date and end date validation settings to control the order of the select list options.

Whichever of the earliest or latest date you put in the start date field would make the year options start at that date and count up or down.

Now though no matter which order you put the dates in the start and end date fields the year select box options always start at the earliest date.

There are two options I can think of to handle this:

  1. Add a new option to control the ordering of years so you can keep start date field supposed to be the earlier date.
  2. Modify the code to store the start and end year as the user entered them before swapping them.

I've included a patch for the second option as that is the simpler to implement and it maintains existing behaviour. Option 1 would mean that behaviour would change until the user edited their date components.

Comments

aBrookland created an issue. See original summary.

harishpatel86’s picture

StatusFileSize
new48.28 KB

Hi aBrookland,

My webform version is : 7.x-4.14

Above patch is not working for select box options in date-picker . i want to a date-picker drop down year/month( Like attached image).
For get the option value in popup in date field i used below jquery , it works to get the drop down Month/year but not inserted in date value in database. Date field value return as blank when i fetch the date from database.

$("#edit-submitted-birth-date" ).datepicker({
changeMonth: true,
changeYear: true,
yearRange: "-100:+0",
});

Forgive me for bad English.

glenshewchuck’s picture

Hi aBrookland,

I re-rolled the patch for 7.x-4.16 and also removed the logic in the form that did a form_set_error if the end date < start date.

glenshewchuck’s picture

Saved previous comment before attaching the patch.

sumachaa’s picture

StatusFileSize
new2.52 KB

Adding a new patch which perform the same. This is referenced from the 8.x version as well (https://www.drupal.org/project/webform/issues/2889770)

Adam_Moulsdale’s picture

Status: Active » Needs review

Changing status to needs review.

The last submitted patch, webform_date_year_options_maintain_user_order.patch, failed testing. View results

gobinathm’s picture

liam morland’s picture

What commit caused the change in behavior? Perhaps it is better to undo that change instead of adding another configuration variable.

lizzjoy’s picture

Issue tags: -#SprintWeekend2018 +SprintWeekend2018

Updated issue tag (removed #)

liam morland’s picture

The validation which can result in the message "The End date must be on or after the Start date" was added in commit bf0ab63 for #2474455: Restrict available choices for select on date and time components. I like the patch in #4 because it avoids the need for another checkbox. Is it compatible with the date picker restrictions implemented in #2474455: Restrict available choices for select on date and time components?

liam morland’s picture

Version: 7.x-4.12 » 7.x-4.x-dev
chris matthews’s picture

The latest patch in #5 to date.inc and WebformTestCase.test still applies cleanly to the latest 7.x-4.x-dev.

However, Liam Morland's last comment was:

The validation which can result in the message "The End date must be on or after the Start date" was added in commit bf0ab63 for #2474455: Restrict available choices for select on date and time components. I like the patch in #4 because it avoids the need for another checkbox. Is it compatible with the date picker restrictions implemented in #2474455: Restrict available choices for select on date and time components?
chris matthews’s picture

Status: Needs review » Postponed (maintainer needs more info)
liam morland’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Drupal 7 is no longer supported. If this applies to a supported version, please re-open.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.