如何在播放框架的表单助手中隐藏标签? [英] How to hide the label in the form helper for the play framework?
问题描述
我有一个表单,用户可以在其中输入问题。每个字段都有一个标签,但在生产环境中,我不想显示标签和某些inputText字段。我试图通过使用'style - >来摆脱它们。 display:none
删除inputText字段,但不删除标签。我在播放框架网站上找不到这样的解释: https://www.playframework .com / documentation / 2.0.4 / JavaFormHelpers
有没有办法通过内置工具来完成这项工作,还是有其他可能性?
@import helper._
@import helper.twitterBootstrap._
@ helper.form( action = routes.Application.sendQuestion()){
< fieldset>
@ helper.inputText(questionForm(questionID),'style - >display:none)
@ helper.inputText(questionForm(questionText))
@helper。输入文字(questionForm(voteScore))
@ helper.inputText(questionForm(ownerID))
@ helper.inputText(questionForm(page))
< / fieldset>
< input type =submitclass =btn btn-default>
例如:
编写您自己的字段构造函数
@(elements:helper.FieldElements)
< div class =@ if(elements.hasErrors){error}>
< div class =input>
@ elements.input
< span class =errors> @ elements.errors.mkString(,)< / span>
< span class =help> @ elements.infos.mkString(,)< / span>
< / div>
< / div>
更多详情 - https://www.playframework.com/documentation/2.0/JavaFormHelpers
I have a form, where the user can enter questions. Every field has a label, but in the production environment I dont want to show the labels and certain inputText fields. I tried to get rid of them by using 'style -> "display: none"
which removes the inputText field but not the label. I did not find an explanation for this on the play framework site: https://www.playframework.com/documentation/2.0.4/JavaFormHelpers
Is there a way to accomplish that with build in tools, or are there other possibilities?
@import helper._
@import helper.twitterBootstrap._
@helper.form(action = routes.Application.sendQuestion()){
<fieldset>
@helper.inputText(questionForm("questionID"),'style -> "display: none")
@helper.inputText(questionForm("questionText"))
@helper.inputText(questionForm("voteScore"))
@helper.inputText(questionForm("ownerID"))
@helper.inputText(questionForm("page"))
</fieldset>
<input type="submit" class="btn btn-default">
}
You can hide the label in the form write your own field constructor, example:
Writing you own field constructor
@(elements: helper.FieldElements)
<div class="@if(elements.hasErrors) {error}">
<div class="input">
@elements.input
<span class="errors">@elements.errors.mkString(", ")</span>
<span class="help">@elements.infos.mkString(", ")</span>
</div>
</div>
For more details - https://www.playframework.com/documentation/2.0/JavaFormHelpers
这篇关于如何在播放框架的表单助手中隐藏标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!