You can try pushing through the built-in field constructors and write your own instead. The following template accepts a custom argument that controls label styles:
app / views / _my_field_constructor.scala.html
@(element: helper.FieldElements) <div class="clearfix @if(element.hasErrors){error}"> <label for="@element.id" class="@element.args.get('_label_class)">@element.label</label> <div class="input"> @element.input </div> </div>
Now use your new field constructor instead of the one you used earlier:
app / views / form.scala.html
.... @* implicitFieldConstructor = @{ FieldConstructor(twitterBootstrapInput.f) } *@ @implicitField = @{ FieldConstructor(_my_field_constructor.f) } ....
When calling a helper function to create an input text field, you can pass the user argument _label_class , which will receive the template:
app / views / form.scala.html
@inputText(orderItem("item1"), '_label -> "Product", '_label_class -> "red", '_class -> "tinytfss")
avik
source share