Closed (works as designed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
forms system
Priority:
Minor
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
17 May 2006 at 09:16 UTC
Updated:
14 Apr 2015 at 20:39 UTC
Jump to comment: Most recent
Comments
Comment #1
drummThis needs review.
Comment #2
dries commentedI don't think this is a problem in forms.inc. It looks like a problem with the calling code ... you should provide such dates to the forms API.
Comment #3
debdungeon commentedThis happened to me when using datetime fields in mysql. The value returned was '0000-00-00' which when rendered as $form['somedate'] = array('#type' => 'date', '#value' => array('day' => 0, 'month' => 0, 'year' => 0)) will result in 1900-01-01 as there is no key value of 0 in any of the selects.
Comment #4
drummInstead of adding another option, can we have it go to today's date instead?
I think a new option needs consideration of things like validation. A required date field needs to have all of the values set.
(And the current convention for Drupal code is to use unix timestamps rather than SQL dates so format_date() may be used on output.)
Comment #5
dries commentedI still think this should be marked "won't fix". If you want the current date, specificy the current timestamp.
Comment #6
debdungeon commentedBut thats exactly my problem. There are a number of date fields like date_of_accident, date_of_bill etc. Some have valid values while others have value of '0000-00-00'. If the 0 key value is not present all date fields for which no specific date value is selected, will be updated to 1900-1-1 or current_date which would be incorrect.
The current cvs version has date_validate function which catches 0000-00-00 dates in case of required date fields.
I personally prefer unix timestamps but I happen to be working on a database provided by the client. I am just developing an interface around the db.
Comment #7
ricabrantes commentedThis bug is active??
Comment #8
sean.mtm commentedI'm looking at essentially the same issue but from a different angle - there's no way to have a null-value with the date selector. To see a case where this would be relevant, I'm making an input for an 'event'. An event may be a single day or it may span multiple days (thus having a start date & an end date). Start date is a required value but the end date is not - a null in the end date would indicate a single-day event.
With the current date input, there is no clear & unambiguous way of not entering a date.
Comment #9
Jaza commentedI agree that this issue is still relevant. @sen.mtm is right: there is no way to not enter a date with the current FAPI date processor.
BTW,
expand_date()is nowform_process_date().Moving.
Comment #10
jhedstromDates can be optional in the form API.