Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I need to provide a date range for my anonymous visitors when they submit a webform (eg. start: +1 day, end: +1 year). Sometimes administrators need to edit each submission and they face the problem: when re-submitting an existing submission (ie. a week old) it's impossible for them to keep the same date because of the validation.
I looked into the code and I've noticed webform_validate_date() really needs a different, more advanced approach:
- It could provide at least a list of checkboxes with all the existing roles so the validation would be triggered for selected roles only,
- The #start_date could be smarter, by checking if the submission date already exists (whether it's a new submission, or an old one). If it's an old one, and #start_date is a relative date - it should be applied on the submission date as a base, not timestamp("now") as it currently is,
- More advanced solution would be to use date tokens for #start_date and #end_date.
Any thoughts?
Comment | File | Size | Author |
---|---|---|---|
#8 | webform-validate_completion_timestamp-2471765-7.patch | 14.07 KB | DanChadwick |
Comments
Comment #1
DanChadwick CreditAttribution: DanChadwick commentedI like a variation on 2 where relative dates for both start and end validate dates are relative to ... some date ... that isn't the current date.
There is another issue relating to what we call the submission date. There are three possible dates:
1) Date submission was first saved to the database (even if draft)
2) Date completed submission was first saved to the database (not as a draft)
3) Date the submission was last saved.
I *think* we are currently storing only 1). I think the right choice would be 2) -- the webform must be valid as of the date it was first completed, even it it isn't valid for when it was first saved as a draft or last updated.
So I think we need to finish #1763668: Submission date shows draft save date first. I'm happy to review and promptly commit patches for that issue and then this one. In other words, I agree with what you want and I'll help, but I don't currently have time to write either patch as I'm working on other webform issues. Unless of course you want to sponsor the feature. I prioritize paid feature requests.
Comment #2
jazzitup CreditAttribution: jazzitup commentedI think this issue is more like a flaw than a feature request, therefore I'm glad you liked one of my proposed approaches. It would be definitely useful for the community.
For now, it's not a high priority for me so I'll create my own (temporary) version of the feature. I'm sorry I don't have a broader scope of the module itself, so my patch would be probably useless for the community, but I'll do my best to help.
Nevertheless, feel free to send me your estimate in case this feature becomes a must for me. Thank you!
Comment #3
srutland CreditAttribution: srutland commented+1 on this. Have bumped into this problem quite a bit when Webform admins need to update a submission that has dates entered based on constraints that are no longer valid to the date when the admin is updating. So thanks for bringing this to light.
In one scenario, a form has a Ticket on sale date that must be +3 weeks from the submission date. When the admin goes to edit the form and the ticket on sale data falls within the +3 weeks at the time of editing, the on sale date must be modified in order to save the form. We have numerous use cases for this problem that I'm sure the community is working around too. Thanks again!
Comment #4
DanChadwick CreditAttribution: DanChadwick commentedIt appears that @jazzitup doesn't plan to post a patch, which is too bad. Some funding would help. Otherwise I prioritize security issues, bugs, patches written by others, and feature requests that are personally interesting -- in that order. :)
Comment #5
srutland CreditAttribution: srutland commentedLOL, that sounds about right on the prioritization. I have to agree with you Dan.
Comment #6
DanChadwick CreditAttribution: DanChadwick commentedNo longer blocked by related issue.
Comment #8
DanChadwick CreditAttribution: DanChadwick commentedWow. That was a lot harder than expected.
This patch:
Phew. This feature cost me about $800 to implement. Funding would be appreciated.
Committed to 7.x-4.x for 4.8.
Comment #9
DanChadwick CreditAttribution: DanChadwick commentedNeeds port to D8.
Comment #10
jazzitup CreditAttribution: jazzitup commentedI knew this would take a much deeper understanding of the module structure in order to make it work. Nice work Dan, well done!
Comment #11
fenstratCommitted and pushed to 8.x-4.x. Thanks!
Comment #13
srutland CreditAttribution: srutland commentedUnbelievable. Thanks Dan, you rock!
Comment #14
DanChadwick CreditAttribution: DanChadwick commentedFund the feature? If I don't get some funding soon, I won't be able to keep this up.