I am newbie to scala
- play frame work
.In my view
page I have plus button
.If I click the plus
button every time It will generate a new row with two text boxes
with delete
icon.If I click the delete
button the current row will be deleted.For example If I entered the values in three rows I need to get the List
of String
values into my Action
for entering into Data Base
.
I need List<String>
values from both contact person
and contact no
into my Controller Action
class for entering values in DB
. I had completed the UI part using javascript
need to work on the form submit
.
Edit
I have done creating a new three
fields with input type id
of contactperson[0],contactperson[1],contactperson[2] and contactno[0],contactno[1],contactno[2]
.If I submit I need to get the contactperson
,contactno
array
values in my controller class.The rows are not pre defined it will generate as many as when click the plus button.
Edit 2
project table
|---------------------------
| projectid | projectname |
|------------------------ |
| 3 | test project |
--------------------------
contact table
|--------------------------------------------------
| conid | projectid |contactperson | contatcno |
|--------------------------------------------------
| 1 | 3 |jamal | 123 |
---------------------------------------------------
|--------------------------------------------------
| 2 | 3 |karthi | 1245 |
---------------------------------------------------
|--------------------------------------------------
| 3 | 3 |gopi | 124 |
---------------------------------------------------
If this is my sample records means how can I use simple
case class projectEdit (
contactperson:List[Options[String]],
contatcno:List[Options[String]],
)
val simple = {
get[List[Option[String]]]("contact.contactperson") ~
get[List[Option[String]]]("contact.contatcno") map {
case contactperson~contatcno
=> projectEdit(contactperson,contatcno)
}
}
I am using https://www.playframework.com/documentation/2.0.2/ScalaForms#Repeated-values how could I map my case
class projectEdit
with scala anorm
like what we usually map the String
,Int
.I don't know how to map the List[Options[String]]
with sql anorm
I have set the hard-coded
values in my simple
variable.So it doesn't make any error on compile/run
time. Let consider I have another variable contactname
in projectEdit
case class projectEdit (
contactperson:List[Options[String]],
contatcno:List[Options[String]],
contactname:String
)
val simple = {
get[String]("contact.contactname") map {
case contactname
=> projectEdit(List(Some("jamal")),List(Some("syed")),contactname)
}
}
In my Action
class I get the values once the form submit
is successful
profileedit =>{
println("contact person list:"+profileedit.contactperson.flatten)
println("contact no list:"+profileedit.contatcno.flatten)
}