I have a form which contains some rows, each has a checkbox in the leading. User can select some of them, then press "delete selected rows" button to submit.
The posted data looks like:
id=1&id=2&id=3
I want to get them in action, my code is:
def delete = Action { implicit request =>
Form("id"->seq(nonEmptyText)).bindFromRequest.fold(
errors => BadRequest,
ids => {
println(ids) // (!)
for(id<-ids) deleteRow(id)
}
)
}
But I found the ids was always List()
, an empty List.
I've checked the "Form samples" provided by play2, and found seq(...)
should only worked with posted data with such format:
company sdfdsf
firstname sdfds
informations[0].email sdf@sdf.com
informations[0].label wef
informations[0].phones[0] 234234
informations[0].phones[1] 234234
informations[0].phones[x]
informations[1].email sdf@sdf.com
informations[1].label wefwef
informations[1].phones[0] 234234
informations[1].phones[x]
informations[x].email
informations[x].label
informations[x].phones[x]
Please notice that there are many [0]
or other indexes in the parameter names.