In my project I need to show drop down field with multiple items selection(more than one). I have done drop down with single selection by using this below code
userRegisterForm.scala.html
@(userForm: Form[User],languages: Seq[(String, String)])
@select(
userForm("languages"),
languages,
'_label -> "Choose Familiar Language", '_default -> "-- Choose Language --",
'_showConstraints -> false
)
What I tried
I added 'multiple ->"multiple" in @select field
but it showed the all list items in drop down when page loaded.It is not like what I need.I have found this multiselect select - Play 2.0? answer from internet but I don't know how to implement those approaches in my project as I am a new to play framework. So anyone please help me to accomplish this task.
The HTML
selecttag doesn't have the capability you're asking for.I'd use one of the plugins. Examples:
You can copy Play's
selecthelper:https://github.com/playframework/playframework/blob/master/framework/src/play/src/main/scala/views/helper/select.scala.html
into your
viewsfolder and modify it to produce the structure required by the plugin that you choose, include the.cssand.jsthen there you have it. :)