我正在使用带有输入助手的 scala 模板。
我使用的类属性应用样式<input>
tag.
我如何应用特定于生成的样式<label>
tag?
@inputText(orderItem("item1"),'_label -> "Product*",'_class -> "tinytfss")
预先感谢您的支持。马诺伊
您可以尝试放弃内置字段构造函数,而是写你自己的 http://www.playframework.com/documentation/2.0/ScalaFormHelpers。以下模板接受控制标签样式的自定义参数:
应用程序/视图/_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>
现在使用新的字段构造函数而不是之前使用的内置构造函数:
应用程序/视图/form.scala.html
....
@* implicitFieldConstructor = @{ FieldConstructor(twitterBootstrapInput.f) } *@
@implicitField = @{ FieldConstructor(_my_field_constructor.f) }
....
当调用辅助函数创建输入文本字段时,您现在可以传入自定义_label_class
模板将选取的参数:
应用程序/视图/form.scala.html
@inputText(orderItem("item1"), '_label -> "Product", '_label_class -> "red", '_class -> "tinytfss")
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)