4
votes

How do you handle multiple checkboxes in Play Framework 2.0 JAVA via GET?

The url looks similar to: http://localhost:9000/games?type=platform&type=role. How can I get both "type" values in a "Set" variable in my controller?

My form looks like this:

<input type="checkbox" name="type[]" class="" value="all-types">
<input type="checkbox" name="type[]" class="" value="platform">
<input type="checkbox" name="type[]" class="" value="role">

Thank you!

1

1 Answers

6
votes

Have a look at http://www.playframework.org/documentation/2.0/ScalaForms , section "Repeated Values":

1) Name the fields type[0], type[1], ....

2) You'll then have in the controller a List[String], out of which you have to look for the checked values.