playframework - Displaying a list of checkboxes in my form -


i want display many checkboxes inline like:

<label class="checkbox-inline">   <input type="checkbox" id="inlinecheckboxa" value="optiona"> </label> <label class="checkbox-inline">   <input type="checkbox" id="inlinecheckboxb" value="optionb"> b </label> <label class="checkbox-inline">   <input type="checkbox" id="inlinecheckboxc" value="optionc"> c </label> 

so have form like:

val form: form[searchform] = form(   mapping(     "letters" -> list(text)   ) 

)(searchform.apply)(searchform.unapply _)

can somehow pre-populate form data or have pass variable view has 'letters' data?

val letters = list[string]("a", "b", "c", ...) 

if can't pass letters val down view, guess pass variable model , iterate on it?

have looked @ helper inputcheckboxgroup ?

that pre-populated form elements model you'll still have provide checkbox group set of possible values.

for example:

@views.html.helper.inputcheckboxgroup(   form("letters"),   options = seq("a" -> "alpha", "b" -> "beta", "c" -> "gamma"),   '_label -> "my cool checkbox" ) 

and form filled with:

val form: form[simpleform] = form(mapping(     "letters" -> list(text)   )(simpleform.apply)(simpleform.unapply))  simpleform.form.fill(simpleform(list("a", "b"))) 

would render checkbox group this:

[x] alpha [x] beta [ ] gamma 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -