I am new to the play framework (I use the Java version). I am looking for a solution to add a selected=”selected” to a field. My code:
@select(settingsForm("projectManager"), options(projectManagers), '_label -> "Project manager" )
The HTML result looks like:
<select id="projectManager" name="projectManager">
<option value="222">Henk</option>
<option value="96">Geert</option>
</select>
Does anyone know the scale argument of the @select field to add the select=selected to the html? The result i am looking for looks like:
<select id="projectManager" name="projectManager">
<option value="222">Henk</option>
<option value="96" select="selected">Geert</option>
</select>
After searching the web for some time, my thought went to the sample projects. The answer was there, right in front of me. Creating only the form with a view is not enough! To make this clearer, just look at the computer-database example. To create a empty field, you just pass a Form object to to the view:
If you want the Form to be filled, you need to pass data to that Form. As the example shows: