2

does anybody know how to add boolean attributes like autofocus to scala templates?

Example: autofocus:

<input autofocus />

For now I use:

'autofocus -> "autofocus"

This prints:

<input type="text" autofocus="autofocus" />

And how to add custom data-attributes? Thanks!

4

2 回答 2

1

使用None,像这样:

@inputText(
  loginForm("username"),
  '_label -> Messages("usernameLabel"),
  'required -> None,
  'autofocus -> None
)

它将输出如下元素:

<input type="text" id="username" name="username" value="" required autofocus>
于 2013-11-20T21:32:14.470 回答
0

这行得通,但我(希望)仍然认为在 scala 中应该有更简单的方法!

'autofocus -> "autofocus"
于 2012-07-27T15:12:29.047 回答