我很难显示包含类的多个对象的表单的错误,在我的例子中是ProductMilestone。基本上,我显示了一个表格中的所有里程碑,显示和更新工作非常好。一旦我得到一个错误,我的模板将不再显示错误"IllegalStateException: No值“。这是因为错误的表单不包含从Form.get()方法接收到的值,在我的示例中是MilestoneSet。在显示错误的情况下,我能做些什么来完成这个工作呢?
问题是视图中的for-循环:
查看:
@(milestoneFormSet: FormProductMilestone.MilestoneSet,productReleaseId: Long) @**函数由for循环调用,形式位于*@@…字段(里程碑: ProductMilestone,索引: Integer) ={ //…其他字段@inputText(milestoneFormSet("milestoneList“+ index + ".initialDate")、”_label ->“、”class -> "“datepicker")…} @form(routes.ProductMilestones.submitEdit(productReleaseId),'id ->“submitMilestoneEditForm”{@*这是问题,当表单出现错误时,我无法使用get在for循环中访问milestoneList *@@for((里程碑,索引) <- milestoneFormSet.get.milestoneList.zipWithIndex) {@->milestone(里程碑,索引)}}
主计长:
公共静态结果submitEdit(Long productReleaseId) { Form filledForm = form(MilestoneSet.class).bindFromRequest();if (filledForm.hasErrors()) {返回productReleaseId productReleaseId);}filledForm{ MilestoneSet newMilestoneSet = filledForm.get();//.update代码}
发布于 2013-08-07 19:00:19
get方法触发验证,因此您不能在视图中使用它,您可以使用另一个变量将set传递给视图。
https://stackoverflow.com/questions/18101702
复制相似问题