Playframework 2 render two dimension form -
I have a form with repeated values: First of all is an action which fills the form if the data fills and needs to be seen. View Assistant Repeat () Method You should consider using it to keep your thoughts clear. Finally, by handling the form in the second action. with a simple case class Form tuple can be improved by changing the code readability.
editPropertiesForm = form (single ( "Sahara" - & gt; seq (long ("color_id" -> longNumber, "size_id" -> longNumber, "quantity" -> longNumber))) < P> What to do next? How to render the table:
Size 1 size 2 ... size color 1 q1_1 q1_2 ... q1_N color 2 q2_1 q2_2 ... q2_n ........... I do not understand the way to group values and present them in the form ....
DEF showForm = Action {passes the passed request to create = & gt; Val SampleData = Seq ((11L, 12L, 13L), (21L, 22L, 23L)) Val form = editPropertiesForm.fill (SampleData) is ok (views.html.form (form))} . Form [seq [(Long, Long, Long:
@ (Form with propForm can override more than seq) ]]) (Underlying request: request header) @ importport assistant. _ & Lt; Form action = "@ Routes form Controller. And fail ()" method = "post" & gt; @ Helper.repeat (proform ("prop")) {row = & gt; & Lt; Input id = "@ line (" color_id "). Id" name = "@ line (" color_id "). Name" value = "@ line (" color_id "). Value" & gt; Id "name =" @ line ("size_id"). Name "value =" @ line ("size_id"). Value "> gt; & lt; input id =" @ line ("volume"). ID "name =" line ("quantity"). Name "value =" @ line ("quantity"). Value ">
def handleForm = Action {The inherent request = & Gt; editPropertiesForm.bindFromRequest.fold (formWithErrors = & gt; BadRequest (views.html.form (formWithErrors)), Prop => {{prop.foreach line => Val colorId = row._1 Val sizeId = Row._2 value = Row._3} OK (prop.toString ())}}}
Comments
Post a Comment