Jamal
Jamal

Reputation: 976

Play Scala Framework multiple dropdown values selection

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.

Upvotes: 0

Views: 1557

Answers (1)

bjfletcher
bjfletcher

Reputation: 11518

The HTML select tag doesn't have the capability you're asking for.

I'd use one of the plugins. Examples:

You can copy Play's select helper:

https://github.com/playframework/playframework/blob/master/framework/src/play/src/main/scala/views/helper/select.scala.html

into your views folder and modify it to produce the structure required by the plugin that you choose, include the .css and .js then there you have it. :)

Upvotes: 1

Related Questions