![Announcement icon Announcement icon](https://www.drupal.org/files/styles/grid-2-2x-square/public/announcements/drupal-evergreen-logo-280X280px%20%281%29_0.jpg?itok=PHpn6rCb)
Quicksketch,
My issue seems very similar to http://drupal.org/node/401954, and if it's a duplicate, I apologize.
I recently upgraded to the newest version and ran update.php, cleared caches.
I wanted to have the years in reverse chronological order, 2011, 2010, 2009, etc., up to 10 years prior.
I was to test the validation of the dates, and was given the message in the provided screenshot. One has the configuration for the range, starting 10 years in the past and going to 10 years in the future.
While attempting to submit a previous date, such as seen in the second screenshot, it would give the validation error.
I'm not using date popup, as you can see.
I was pretty sure this wasn't the case with 2.x, as I set up the form with the intention of this date range displaying the current year and all years previously, and hadn't had any users complain of not being able to validate the date.
Do I need to just use the textfield instead, and have users enter the year?
Comment | File | Size | Author |
---|---|---|---|
#8 | webform_date_flip.patch | 1.51 KB | quicksketch |
entered_date.JPG | 48.34 KB | narcissus921 | |
date_range.JPG | 87.34 KB | narcissus921 |
![Acquia logo](/files/ads/acquia-issue-sponsorship.png)
Comments
Comment #1
narcissus921 CreditAttribution: narcissus921 commentedComment #2
jennypanighetti CreditAttribution: jennypanighetti commentedI have this exact same problem. I originally had my dates -5 to -100 so the most recent years would appear on top, but now my users get a validation message saying they have to be WITHIN 5 years, not AT LEAST 5 years ago. I swapped the max and min to get the validation to work correctly, but now my year starts at 1911, not 2006.... and most of my users are teens...
Comment #3
quicksketchI think there are actually 2 issues being described here. The initial post with the screenshots is actually showing an error in which Webform is correct. If the start date is "-10 years" and the end date is "+10 years", you should get an error if your end-user date is more than 10 years ago. The screenshot shows a good example, the date entered was in May, but its currently September. So May 10 years ago is actually 10 years and 4 months ago. It should throw an error.
Although it's a bit awkward, you can solve this problem by using a Start Date of "Jan 1 - 10 years", meaning any date in all of 2001 will be allowed, even the days before the current one. Likewise your end date would need to be "Dec 31 + 10 years".
So the subject of this post (as well as the screenshots) show one problem. But the original post and comment #2 describe another problem, which does indeed seem to be broken behavior. If your end date is before your start date, it should flip the order of the "Year" drop down list (which it does correctly), but then the form won't let you submit. Instead of flipping start and end date, it actually validate the start date (which is actually later) as the start date and the end date as the end date. Looks like our validation just needs a fix.
Comment #4
narcissus921 CreditAttribution: narcissus921 commentedThanks for the clarification! I wasn't sure what was going on (obviously, since I was going back more than my date range..), but that definitely makes sense. Given what you've provided about defining specific start and end dates dates, I'm going to go try those out.
Comment #5
narcissus921 CreditAttribution: narcissus921 commentedReferring back to the issue I had originally referenced as a similar/near duplicate issue, I noticed the patch that was included on the thread (http://drupal.org/files/issues/webform_reversible_dates.patch) and didn't see this in the code anywhere.
I'm not a programmer, but I didn't see anything related to this in the date.inc file anymore?
Comment #6
Bartezz CreditAttribution: Bartezz commentedUpdated to latest version and had start date of -18 and end date of -99 which worked before the update.
Now I changed it to '18 year ago' and '99 year ago' and it has problems validating.
It only works if I reverse the order and input '99 year ago' and '18 year ago'.
Is the 'bug' mentioned in #1 back?
Cheers
Comment #7
quicksketchWell it's not really "back", because it hasn't been fixed yet. That's why this issue is still in the "active" state. The bug exists in all versions higher than 3.12.
Comment #8
quicksketchI've committed this patch which fixes the validation to make it so that start and end dates can be flipped.
Comment #9
Bartezz CreditAttribution: Bartezz commentedThanx!
Comment #11
bcobin CreditAttribution: bcobin commentedI know this is an old issue, but this seems to the latest it's been addressed - the patch from four years ago no longer applies. Reversing the order as described above generates the "end date must be later than start date" message and the form won't validate.
Any ideas? Thanks!
Comment #12
DanChadwick CreditAttribution: DanChadwick commentedThe start date needs to be before (or equal to) the end date during submission entry. This was added when tokens were added. For example, you might have a range from [sometoken:date] to [1/1/2016]. So you want to allow entries from the token date, ending on 1/1/2016. If the form is submitted on 2/2/2016, there should be no allowable value (because, say, the coupon has expired).
Or maybe I'm not understanding why "flipped" start/end dates are useful?
Comment #13
bcobin CreditAttribution: bcobin commentedThanks for the response, @DanChadwick; my issue is the same as @jenstechs, some four years ago. It's a display thing, not functionality-related, so in my case, it's not a bug in any sense of the word.
This is for a site for a quasi-governmental program that's repurposing an abandoned brewery space and local craft brewers are prospective tenants. Craft brewers are required by law for visitors to attest that they are of drinking age, which I'm doing via a web form with a dropdown date selector; having to scroll all the way from 1915 to more recent years is very tedious.
So I just need to be able to display the year in descending, as opposed to ascending order. This would be much more user-friendly.
Does that make sense? Thanks for the response, or perhaps I should say... Cheers!
Comment #14
DanChadwick CreditAttribution: DanChadwick commentedYeaaaah, I'd say that reversing the order of the fields for validation isn't the right way to achieve this though. I think you'll have to do some custom programming to get this feature back.
Or, gag, I guess we could consider an option to present years most-recent first.
Comment #15
bcobin CreditAttribution: bcobin commentedThere could be a beer in it for ya. If you're over 21, that is! :)
Comment #16
Anonymous (not verified) CreditAttribution: Anonymous commentedSame problem, running 7.x-4.10. Is there any progress towards fixing this or offering a patch?
Webform is great and just what we need – but having a dropdown for years in reverse order would be very helpful.
Thanks!
Comment #17
DanChadwick CreditAttribution: DanChadwick commented@16 - No. No one is working on this, but I would happily review a patch.
Comment #18
waluyo.umam CreditAttribution: waluyo.umam as a volunteer commentedI have the same problem (webform 7.x-4.12) cannot get the dropdown for years in decending order.
Comment #19
sumachaa CreditAttribution: sumachaa commentedA patch for this in 4x is added in here: https://www.drupal.org/project/webform/issues/2718593