1
我使用“播放2.0” -framework(诉2.0.1),并运行到一些麻烦与日期值的表单验证。播放2.0形式的日期验证失败
和平的我的模型代码:
<input type="text" id="start" name="start" placeholder="yyyy-mm-dd" />
<!-- ALSO tested with chrome beta v. 20 with html5 support-->
<input type="date" id="end" name="end" placeholder="yyyy-mm-dd" />
我的控制器:
public class Appointment extends Controller {
static Form<Appointment> appointmentForm = form(Appointment.class);
//on calling form page
public static Result create() {
return ok(create.render("create", appointmentForm));
}
//called on saving form data
public static Result save() {
Form<Appointment> filledForm = appointmentForm.bindFromRequest();
if (filledForm.hasErrors()) {
return badRequest(
create.render("create", filledForm)
);
} else {
Appointment.create(filledForm.get());
return redirect(routes.Appointment.index());
}
}
}
如果我选择通过jQuery UI的日期选择日期或
我的模板代码@Entity
public class Appointment extends Model {
public Date start;
public Date end;
}
和平以“yyyy-mm-dd”的格式输入我自己的内容或无关紧要,但必须是正确的格式,我遇到了一个vali在我的控制器save()方法错误 - 检查“filledForm.hasErrors()”的方法和错误消息“错误的日期格式”。
我认为它会自动从游戏中进行转换,这样我就不用自己一个添加皈依。我能做些什么来解决这个问题?玩2.0还是个问题吗?
Thanky you。
干杯,
马尔科