I'm creating a form in Play using the following code:
@inputText(loginForm("password"),
'type -> "password",
'_label -> null)
It generates the following HTML code:
<dl class=" " id="password_field">
<dt><label for="password"></label></dt>
<dd>
<input type="password" id="password" name="password" value="">
While I want it to generate:
<input type="password" id="password" name="password" value="">
Is there an easy way of doing this?
You can achieve this by creating a custom FieldConstructor (see http://www.playframework.com/documentation/2.3.x/ScalaCustomFieldConstructors).
Create a new file
views/helper/myPlainFieldConstructor.scala.html
that contains the following:[For reference, you can see the default field constructor here.]
Then, in the view template containing your form:
Note: If you really need
value=""
, you can add'value -> ""
to the helper's arguments, i.e.Or further customize the HTML with the generic
input
helper, as in: