Play Framework 2.0 form helper: from checkbox to List<String>

Viewed 8655

I have a model that contains a String and a list:

public String title;    
public List<String> topics;

In index.scala.html I use a form to add new items:

@form(routes.Application.newPaper()) {
    @inputText(paperForm("title"))
    <input type="submit" value="Create">
    }

with a simple String, this works nicely. But I would like to show checkboxes

@for(t <- topics) {
    <input type='checkbox' name='topic' value=@t>@t <br>
}

and subsequently add all checked 'topics' to the List<String> topics; of my new item. How can I process the checkboxes within @form{ ... }?

1 Answers
Related