I have a simple Book domain.
class Book {
String title
Date published
static constraints = {
}
}
I have created a simple form for book creation
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<title></title>
</head>
<body>
<g:form action="save">
Title: <g:textField name="title"></g:textField>
<br>
Published:
<input type="text" name="startDateTime_dayMonthYear" id="startDate" value="01/06/2022" maxLength="10" size="8" pattern="^\d{1,2}/\d{1,2}/\d{4}$" placeholder="mm/dd/yyyy" />
<input type="text" name="startDateTime_hourMin" id="startDateTime_hourMin" value="8:00" maxLength="5" size="3.5" pattern="^([1-9]|[1][0-2]):[0-5][0-9]$" autocomplete="off" placeholder="hh:ss" />
<select name="startDateTime_meridian" id="startDateTime_meridian" >
<option value="AM" selected="selected" >AM</option>
<option value="PM" >PM</option>
</select>
<select name="startDateTime_timeZone" id="startDateTime_timeZone" >
<option value="US/Hawaii" >(GMT-10:00) US/Hawaii</option>
<option value="US/Alaska" >(GMT-09:00) US/Alaska</option>
<option value="US/Pacific" >(GMT-08:00) US/Pacific</option>
<option value="US/Arizona" >(GMT-07:00) US/Arizona</option>
<option value="US/Mountain" selected="selected" >(GMT-07:00) US/Mountain</option>
<option value="US/Central" >(GMT-06:00) US/Central</option>
<option value="US/Eastern" >(GMT-05:00) US/Eastern</option>
<option value="US/East-Indiana" >(GMT-05:00) US/East-Indiana</option>
</select>
<br>
<g:submitButton name="Submit"></g:submitButton>
</g:form>
</body>
</html>
create and save actions are as follows
def create(){
}
def save(){
def book = new Book()
bindData(book, params)
book.save()
redirect(actionName: "index")
}
For referance the form looks like this
Is there a way to bind the published date property with this multi field date structure? I know the way to bind date in grails 4 from single text field but with multi fields like this i cannot find resource on how to do it.
I am using grails 4.0.10. I appreciate any help. Thanks!