user2975535 user2975535 - 3 months ago 30
Scala Question

Play Framework how to set selected option in the form?

I need to set selected option for select element, rendered with Play Framework helper.
In the docs$ I didn't find example how to do it.
I tried to do it like this, but still default value is selected:

field = form("selectedCategory"),
options = categoriesSeq,
'_default -> "Choose One",
'_label -> "Select category",
'selected -> "1"

I think this should be possible to achieve somehow.


You may want to look at how use play forms.

In your code, what is the variable form?

It should be a instance, passed into your view, from your controller.

I hope this helps.