如何在play框架的表单助手中隐藏标签?

ham*_*314 1 java forms playframework

我有一个表单,用户可以在其中输入问题.每个字段都有一个标签,但在生产环境中我不想显示标签和某些inputText字段.我试图通过使用'style -> "display: none"删除inputText字段而不是标签来摆脱它们.我在play框架网站上没有找到解释: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.inputText(questionForm("voteScore"))
            @helper.inputText(questionForm("ownerID"))
            @helper.inputText(questionForm("page"))
        </fieldset>
        <input type="submit" class="btn btn-default">
    }
Run Code Online (Sandbox Code Playgroud)

Sak*_*tal 5

您可以在表单中隐藏标签,编写您自己的字段构造函数,例如:

编写自己的字段构造函数

@(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>
Run Code Online (Sandbox Code Playgroud)

有关详细信息,请访问https://www.playframework.com/documentation/2.0/JavaFormHelpers