Playframework 2 render two dimension form -


itemprop = "text">

I have a form with repeated values:

  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 ....   

itemprop = "text">

First of all is an action which fills the form if the data fills and needs to be seen.

  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: 

View Assistant Repeat () Method

  @ (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 "> ; input type =" submit "value =" send ">    

You should consider using it to keep your thoughts clear.

Finally, by handling the form in the second action.

  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 ())}}}   

with a simple case class Form tuple can be improved by changing the code readability.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -