且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在播放框架中填充HTML下拉列表

更新时间:2023-10-25 22:58:04

首先在视图的开头导入helper包:

First import helper package(s) at the beginning of your view:

@import helper._

因此您可以使用该示例:

So you can use that sample:

@select(
   gameForm("game_duration"),
   options(Seq("01 hour","02 hour","03 hour","Never end")),
   '_label -> "Game duration", '_default -> "-- Select duration --"
)

或者,您也可以使用该代码而无需事先导入helper软件包

Alternatively you can also use that code without previous importing helper package(s)

@helper.select(
   gameForm("game_duration"),
   helper.options(Seq("01 hour","02 hour","03 hour","Never end")),
   '_label -> "Game duration", '_default -> "-- Select duration --"
)

重要:如果Seq(...)版本在编译时失败,请尝试使用options(List("01 hour","02 hour","03 hour","Never end")).

important: Try to use options(List("01 hour","02 hour","03 hour","Never end")) if Seq(...) version will fail while compiling.

顺便说一句,使用数字值(即int-更易于在数据库中存储和搜索)可能会更好:

btw, most probably it would be better using numeric values (ie int - easier to store and search in DB):

...
helper.options("60" -> "01 hour","120" -> "02 hour","180" -> "03 hour", "9999" -> "Never end"),
...

还请检查此答案以获取更多示例

Also check this answer for more samples