Ducaz035
Ducaz035

Reputation: 3132

How to populate drop down box from conf file using Scala / Play Framework

Firstly, I am using play framework 2.1.1 with Scala. I would like to add create a drop down box with name but when the user selects it , it should give me the id of the selected name in drop down box.

Secondly, In order to achieve that i would like to use a conf file or sth. similar to it. I am open to new ideas and fancy ways to implement that. I need the value(id) in my controller. In addition, i can use play framework helpers as well.

Cheers

Upvotes: 0

Views: 261

Answers (1)

egprentice
egprentice

Reputation: 824

IDEA: In your configuration file, keep the association between name and id as a pair. Read the file using the typesafe configuration library. Then save the values you have read in from the config file in a data structure. When you are creating the view template that has the drop down box, read the data structure to get the name,id pairs and send those to the browser.

Upvotes: 2

Related Questions