If you set a date field as required, it will be populated with today's date/time even if the default value is set to "blank". Even though the field is required, it should be blank and show an error on submit when left empty.
1) type of field: date
2) type of widget: text
3) timezone option: any
4) no multiples
5) yes required
I'll see if I can find the problem and submit a patch later...
Comments
Comment #1
threexk commentedI agree with wazdog's assessment of how it should work. Could not figure out why it was populating the current date until I saw this post.
Comment #2
karens commentedThe problem is that when you mark a date required it doesn't include a blank value option for any of the date parts, which seems like a logical way for it to behave. I changed the code to provide a blank value if the date is required but empty so now I just need to watch this for a while to be sure it doesn't introduce any other problems now that non-allowed values are in the options list.
Comment #3
threexk commentedKaren, thanks for the fix but it doesn't seem to blank text fields, just select lists. (Many of our date fields are preferably text fields to speed data entry.)
I agree with you it is logical to default a valid value for a required field. However, the problem we in particular are having is that on our medical website we need to capture correct dates, for instance birth dates, but it is all too easy for a user to submit the form without changing the default date. So we end up with many birthdays being the current date. (Good validation should catch this, but for other date fields the current date is a valid entry too!) A blank required date will always force the user to enter a date.
Using the 4-18-08 dev snapshot.
Comment #4
karens commentedI understand the use case for this, I just forgot to go back and get this working with text fields as well as select lists :)
Working on this now...
Comment #5
karens commentedOK, textfield dates should now be working. Let me know if there are problems.
Comment #6
threexk commentedThe textfields come up blank now, but won't submit when filled in. I get the following form errors from two date textfields:
A valid date cannot be created from
A valid date cannot be created from
The input format is specified as 04/22/2008 - 00:09:28, and I have only month, day, and year checked.
May not be related, but I also see extra vertical space between the form label and textfield. Poked into with Firebug, and found the field curiously contains two form-items:
Comment #7
karens commentedMarking back to active until I get it fixed.
Comment #8
karens commentedOK, the empty but required textfield should now be working right with the latest commits.
The extra form div is because we are nesting elements and the inner one is automatically created by core. Not sure I can do anything to get rid of it, but at any rate is doesn't affect this problem and isn't critical.
Comment #9
threexk commentedFix works, thanks!
Comment #10
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #11
threexk commentedThe To Date is not blanked; it always has a default value. I am using the following settings:
Widget: Select List
Default value: Blank
To Date: Optional
Sorry, I didn't test this case before.
Comment #12
karens commentedOpen up the advanced default options to set a default value for the to date.
Comment #13
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #14
graemec commentedKaren,
Do you know where I can download this patch that you and threexk are referring to?
Much appreciated.
Comment #15
threexk commentedgraemec: 5.x-2.x-dev has this code in it. If a patch to 5.x-2.0-rc is what you need though, maybe Karen could provide that. I don't immediately know how to build a patch off the associated commits.