I have a Form with a nested list of mappings, but have problems iterating this in the template. The Form looks like this
val assignmentForm : Form[AssignmentData] = Form(
"acceptedSign" -> nonEmptyText(),
mapping("activities" -> list (
mapping("activityId" -> optional(text),
"activityStatus" -> optional(text))
(ActivityData.apply)(ActivityData.unapply))
)(AssignmentData.apply)(AssignmentData.unapply)
)
I am passing this form into the template and try to iterate over the activities. So far only compiler errors or a complete metadata dump of the Form as a result.
This gives a metadata+data dump of the complete form, with the activity included. (the LI tag is a tab navigator that will contain input fields)
@repeat(assignmentForm("activities")) { activity =>
<li>@activity("activityId")</li>
}
Iteration sort of works (is the code runs), but it is completely unusable from a user standpoint.
I have also tried various for-loops, only giving me compiler errors, saying
value map is not a member of play.api.data.Field
My questions are:
- Is it supposed to be possible to construct such a form, and how is it done?
- What other options do I have for rendering input forms with one-to-many relationsships?