0
我想在Scala中为Play框架构建一个输入助手。如何定义复选框的自定义scala输入助手
我希望我的输入类型radio
和checkbox
的打印方式与标准的text
或password
输入类型不同?
这里是我的自定义帮助:
@(elements: helper.FieldElements)
<div class="form-group">
<label for="@elements.id" class="col-lg-2 control-label">@elements.label</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="@elements.id" />
</div>
</div>
但这打印出text input
而不是checkbox input
。这是奇怪的行为。
我已阅读文档,但无法找到任何有关它的信息。
这是我如何导入此helper
到view
:
@implicitFieldConstructor = @{ FieldConstructor(generic.views.html.FormHelpers.twitterBootstrapInputSupraClub.render) }
@checkboxFieldConstructor = @{ FieldConstructor(generic.views.html.FormHelpers.twitterBootstrapInputSupraClubCheckbox.render) }
这是我如何调用助手构建输入(生成输入)在view
:
@inputText(
accountRegistrationForm("email"),
'_label -> "email"
)
@inputPassword(
accountRegistrationForm("password"),
'_label -> password
)
@inputRadioGroup(
accountRegistrationForm("regulationAcceptance"),
options = Seq("true"->"Yes"),
'_label -> "I agree with regulation",
'type -> "radio"
)(handler = checkboxFieldConstructor, implicitly[Lang])
你可以给我@inputText(accountRegistrationForm('的一个例子”电子邮件“),'_label - >”email“)'用法与你的例子? – masterdany88
看我上面编辑 –
你的助手叫什么,你打电话给你怎么样? –