我有一個包含一些行的表單,每個表單中都有一個複選框。用戶可以選擇其中一些,然後按「刪除選定的行」按鈕進行提交。如何在play2中獲取發佈的「id = 1&id = 2」?
張貼的數據是這樣的:
id=1&id=2&id=3
我想他們在行動上,我的代碼是:
def delete = Action { implicit request =>
Form("id"->seq(nonEmptyText)).bindFromRequest.fold(
errors => BadRequest,
ids => {
println(ids) // (!)
for(id<-ids) deleteRow(id)
}
)
}
但我發現IDS總是List()
,一個空列表。
我已經檢查由play2提供的「樣品表」,發現seq(...)
只能用這樣的格式發佈數據的工作:
company sdfdsf
firstname sdfds
informations[0].email [email protected]
informations[0].label wef
informations[0].phones[0] 234234
informations[0].phones[1] 234234
informations[0].phones[x]
informations[1].email [email protected]
informations[1].label wefwef
informations[1].phones[0] 234234
informations[1].phones[x]
informations[x].email
informations[x].label
informations[x].phones[x]
請注意,有許多[0]
或其他指標的參數名。