Question

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!

Was it helpful?

Solution

Use None, like this:

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

It will output an element like this:

<input type="text" id="username" name="username" value="" required autofocus>

OTHER TIPS

This works, but still I (hope) think there should be an easier way in scala!

'autofocus -> "autofocus"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top