更新时间:2023-10-25 22:44:40
First import helper
package(s) at the start of your view:
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 --"
)
重要: 尝试使用 options(List("01 hours","02 hours","03 hours","Never end"))
如果 Seq(...)
版本在编译时会失败.
important: Try to use options(List("01 hour","02 hour","03 hour","Never end"))
if Seq(...)
version will fail while compiling.
顺便说一句,很可能使用数值会更好(即 int
- 更容易在 DB 中存储和搜索):
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