@repeat
is enormously useful; however, I am hitting a road block with nested forms.
I need to produce a form for a schedule of games, which has 2 attributes, schedule data (game date, time, location, opponent) and submitting team notes (e.g. "due to a winter storm the game on January 7th has been moved to January 9th in...Hawaii ;-)")
Form mapping is based on:
case class Schedule(
composite: Seq[Composite],
note: Seq[ScheduleNote]
)
and then to display the form in a template I have:
@repeat(_form("composite"), min=numGames) { f=>
@inputDate(f("gameDate"), 'id-> "gameDate", '_label-> "Game Date")
....
}
@repeat(_form("note"), min=numGames) { f=>
@inputDate(f("gameNote"), '_label-> "Game Notes")
....
}
of course game notes need to be paired with game data, which will not happen in the above since it looks like I need to @repeat
composite game data and notes separately.
It would be really, really nice to:
@repeat(_form("composite").zip(_form("note")), min=numGames) { case(fc,fn)=>
over the nested form elements.
Is there anyway I can pull this off? Looking at the source it appears not, but perhaps with a pimp my library it's possible (or, since I'm building against 2.1, hack something in place until the framework supports what seems to be a limitation)
EDIT
Actually, my original attempt doubled the number of produced fields; this one generates the correct number of fields:
Still TBD if edit form maps form data values properly....
ORIGINAL
Experimenting, this compiles:
and does generate game data and notes together as desired.
As to whether or not it works on form edit, TBD ;-)