Reputation: 83
I have a form where I define:
@Required
@Formats.DateTime(pattern="dd/MM/yyyy")
public Date mDate;
Now my in template I have:
@helper.inputDate(
myForm("mDate")
)
But when I submit the form I get an error as invalid value.
Upvotes: 2
Views: 2947
Reputation: 71
Check type of mDate field. It must be java.util.Date
, not java.sql.Date
.
Upvotes: 3
Reputation: 1739
This is really late, but hopefully it will be helpful to people who stumble upon this question.
If you go into chrome dev tools or firebug you'll see something like this when the error message is displayed:
<input type="date" id="start" name="start" value="2013-12-31">
That means the format sent back to the server is yyyy-MM-dd instead of dd/MM/yyyy.
Change the model field decorator to this:
@Required
@Formats.DateTime(pattern = "yyyy-MM-dd")
public Date mDate;
Upvotes: 5