开发者

How to get form field array in play framework

I'm using groovy to render templates in Pl开发者_StackOverfloway framework. I have a checkbox inside a list loop:

<input type="checkbox" name="chkUser[]" id="chkUser{users.getId()}" value="${users.getId()}">

How can i get the state of the checkbox array in Controller page.


Came across this a couple of monthes ago. It seems you can use find those back in controller using :

public static myFormFunction(boolean[] chkUser) {
...

Not sure of it and I cannot check this right now. Take a look at the official documentation.


It can be achieved using hidden fields for every checkbox.

<input type="hidden" name="HdChkUser${users.getId()}">
<input type="checkbox" name="ChkUser${users.getId()}">

If the state of the checkbox changes then updating the hidden field value. Which can be used in for msubmission.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜