我正在尝试使用PlayFramework日期映射和datetime-local字段。 Docs Here
截断的映射看起来像这样,有一些我为验证器尝试过的选项。
mapping(
"startTimeGt" -> optional(jodaDate),
"startTimeLt" -> optional(jodaDate("dd-MM-yyyy HH:mm"))
)(...
我已经尝试了捆绑的inputDate帮助器和datetime-local字段。
但是我尝试尝试的任何组合都会在表单提交上得到一个
error.date
。我觉得这应该很简单,或者我在文档中丢失了一些内容,或者他们只是不告诉我。有没有人得到所需的html和jodaDate
映射的有效示例? 最佳答案
我猜formWithErrors是由代码引起的
"startTimeLt" -> optional(jodaDate("dd-MM-yyyy HH:mm"))// the format maybe wrong
因为您不知道jodaDate从前端传递到后端的格式。您可以像这样从请求绑定表格之前打印表格内容
def index() { implicit request =>
println(request)//it will print the request content and you can find the "startTimeLt" to verify its format
form.bindFromRequest.fold...
}
祝好运