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:
- Add a new option to control the ordering of years so you can keep start date field supposed to be the earlier date.
- 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.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | webform-yearreverse-2718593-4.patch | 2.52 KB | sumachaa |
| #4 | webform_date_year-maintain_user_order-2718593-3.patch | 1.42 KB | glenshewchuck |
| #2 | weform_date_popup issue.png | 48.28 KB | harishpatel86 |
Comments
Comment #2
harishpatel86 commentedHi 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.
Comment #3
glenshewchuck commentedHi 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.
Comment #4
glenshewchuck commentedSaved previous comment before attaching the patch.
Comment #5
sumachaa commentedAdding 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)
Comment #6
Adam_MoulsdaleChanging status to needs review.
Comment #8
gobinathmComment #9
liam morlandWhat commit caused the change in behavior? Perhaps it is better to undo that change instead of adding another configuration variable.
Comment #10
lizzjoyUpdated issue tag (removed #)
Comment #11
liam morlandThe 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?
Comment #12
liam morlandComment #13
liam morlandComment #14
chris matthews commentedThe 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:
Comment #15
chris matthews commentedComment #16
liam morlandDrupal 7 is no longer supported. If this applies to a supported version, please re-open.