基于@JacobusR's answer如何在控制器中编写一个表单,允许我将其作为Form类型发送到视图,并且所有单面表列映射和多边表seq-mapping?< / p>
这样的事情:
在控制器
中private val DirectorateAndItsServiceAreas: Form[???] = Form(
mapping(
"dirCode" -> nonEmptyText,
"name" -> text,
"serviceAreaRow" -> seq( /* don't have and don't want serviceAreasRow in Directorate table */
mapping(
"areaCode" -> nonEmptyText,
"dirCode" -> nonEmptyText,
"name" -> text
)(ServiceArea.apply)(ServiceArea.unapply)
)
)(Directorate.apply)(Directorate.unapply)
)
在视图中
@(DirectorateAndItsServiceAreasForm: Form[Directorate/ServiceArea],...