Details
-
Type:
Sub-task
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 1.0-RC1
-
Fix Version/s: 1.1-beta3
-
Component/s: Persistence, TagLib
-
Labels:None
Description
As described on http://www.nabble.com/Date-not-valid%3A-date-can-be-null--tf4759422.html empty date fields cannot be persisted, resulting in an invalid date error message.
Using noSelection attribute as in
<g:datePicker name="myDate" value="$
{new Date()}" noSelection="['':'-Choose-']"/>
does not work.
Issue Links
- is duplicated by
-
GRAILS-1530
datePicker noSelection does not work when editing a already persisted date
-
-
GRAILS-2556
Property offeringDate must be a valid Date even if that field allows null
-
-
GRAILS-3981
CLONE -Property offeringDate must be a valid Date even if that field allows null
-
- relates to
-
GRAILS-4922
Empty date gives typeMismatch.java.util.Date
-
A workaround is:
1) use g:datePicker undocumented default="..." attribute in the view
<g:datePicker name="myDate" value="$
{new Date()}" noSelection="['':'-Choose-']" default="none"/>
2) remove the field from the map used for binding if some/all fields is/are empty
def excludes = []
if (!params.myDate_day)
excludes << "myDate"
bindData(myDomainObject, params, excludes)
(note that this has to be done in both save and update and that bindData has to be used rather than properties assignment)