【问题标题】:How to hide the label in the form helper for the play framework?如何在播放框架的表单助手中隐藏标签?
【发布时间】:2015-06-02 09:24:43
【问题描述】:

我有一个表单,用户可以在其中输入问题。每个字段都有一个标签,但是在生产环境中我不想显示标签和某些 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.inputText(questionForm("voteScore"))
            @helper.inputText(questionForm("ownerID"))
            @helper.inputText(questionForm("page"))
        </fieldset>
        <input type="submit" class="btn btn-default">
    }

【问题讨论】:

    标签: java forms playframework


    【解决方案1】:

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

    编写你自己的字段构造函数

    @(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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-30
      • 1970-01-01
      • 2012-05-23
      • 1970-01-01
      • 2013-04-12
      相关资源
      最近更新 更多