grails - forcing select list values to be saved as date to oracle db
I'm working on an app to track sessions for a conference and want to allow the user to select dates from a drop down but have the dates stored as a date in the oracle database. I've tried using the date 开发者_如何学Cpicker but want to limit the options. Here is the code I am currently using.
<g:select name="sessionDate" from="${session_MasterInstance.constraints.sessionDate.inList}" value="${formatDate(format:'mm/dd/yyyy', date:session_MasterInstance?.sessionDate)}" noSelection="['null': '']" />
The values I want to display do display correctly but when I try to create a new record I receive Propery sessionDate must be a valid Date
I have sessionDate(nullable:true, inList:["11/21/2011","11/22/2011"])
in my domain class and sessionDate of Date format in my Oracle DB.
Please advise. I'm new to grails so this is probably very simple.
It might be this issue: GRAILS-6604 (there's a workaround there for pre-1.3.6).
What Grails version are you using?
I'm in doubt about inList
that contains String
s for values. If this constraint produces errors, I'd try inList: [new Date(2011, 11, 21), new Date(2011, 11, 22)]
.
精彩评论