Scala Play框架:将表单参数绑定到隐藏字段 [英] Scala Play framework: Binding form parameters to hidden fields

查看:67
本文介绍了Scala Play框架:将表单参数绑定到隐藏字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Play 2.0.4,并且在我的Scala模板中具有以下形式.

I am working with Play 2.0.4 and have the following form in my scala template.

@fieldGroup(field: Field, className: String = "field") = {
<div class="twipsies well @className">

    <a class="removeField btn danger pull-right">Remove Field</a>

    @inputText( // <=== I need a hidden input field here
        field("id")
    )

    @inputText(
        field("name"),
        '_label -> "Name",
        '_help -> "Use lower case, starts with an alphabet can contain numbers and underscores."
    )
}

我在表单中需要一些隐藏字段,如何将其绑定到服务器端 Form 组件?我在github存储库中看到了一个 @inputHidden 模板帮助器,但是在稳定版本中不可用.如何完成我想要的?谢谢.

I need a few hidden fields in my forms, how do I bind it to the server side Form component? I have seen a @inputHidden template helper in the github repository but it is not available in the stable release. How do I accomplish what I am looking for? Thanks.

推荐答案

将其手动"编写为通用HTML:

Write it 'manually' as common HTML:

<input type="hidden" name="id" value='@field("id").value' >

或使用自己处理HTML输入创建中的文档中所述的方法. strong>部分.

or use a way described in the documentation in Handling HTML input creation yourself section.

这篇关于Scala Play框架:将表单参数绑定到隐藏字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆