Playframework Scala模板将样式应用于inputText';s标签[Play 2 HTML5助手标签]

Playframework Scala模板将样式应用于inputText';s标签[Play 2 HTML5助手标签],playframework,playframework-2.0,scala-template,Playframework,Playframework 2.0,Scala Template,我正在使用带有输入助手的scala模板 我使用的class属性应用于标记的样式 如何将特定样式应用于生成的标记 @inputText(orderItem("item1"),'_label -> "Product*",'_class -> "tinytfss") 提前感谢您的支持。Manoj您可以尝试抛弃内置的字段构造函数,而不是。以下模板接受控制标签样式的自定义参数: app/views/\u my\u field\u constructor.scala.html @(elemen

我正在使用带有输入助手的scala模板

我使用的class属性应用于
标记的样式

如何将特定样式应用于生成的
标记

@inputText(orderItem("item1"),'_label -> "Product*",'_class -> "tinytfss")

提前感谢您的支持。Manoj

您可以尝试抛弃内置的字段构造函数,而不是。以下模板接受控制标签样式的自定义参数:

app/views/\u my\u field\u 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>
....
@* implicitFieldConstructor = @{ FieldConstructor(twitterBootstrapInput.f) } *@
@implicitField = @{ FieldConstructor(_my_field_constructor.f) }
....
@inputText(orderItem("item1"), '_label -> "Product", '_label_class -> "red", '_class -> "tinytfss")
调用helper函数创建输入文本字段时,现在可以传入模板将拾取的自定义
\u label\u class
参数:

app/views/form.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>
....
@* implicitFieldConstructor = @{ FieldConstructor(twitterBootstrapInput.f) } *@
@implicitField = @{ FieldConstructor(_my_field_constructor.f) }
....
@inputText(orderItem("item1"), '_label -> "Product", '_label_class -> "red", '_class -> "tinytfss")

我自己也遇到了这个问题,但我能够在不使用自定义FieldConstructor的情况下解决它。我所做的只是将表单帮助行更改为包含表单id,然后在css中引用该表单的标签。像这样:

scala模板文件:

    <style>
        #new-tenant-form label {
            font-weight: bold;
        }
    </style>

. . .

    @helper.form(routes.Tenants.create(), 'id -> "new-tenant-form") {
           . . . 

#新租户表格标签{
字体大小:粗体;
}
. . .
@helper.form(routes.Tenants.create(),'id->“新租户表单”){
. . . 

感谢您的热情和慷慨支持。效果非常好。!相关