【问题标题】:Play 2.2 Scala: Default values for a simple formPlay 2.2 Scala:简单表单的默认值
【发布时间】:2014-04-24 00:05:02
【问题描述】:

目前,我有一个简单的表单,即Form[(String, String, String)]

在我的 scala.html 文件中:

    @form(routes.Application.editParticipant(pid)) {
    @inputText(pForm("email"),'_label -> "Email", '_showConstraints -> false, 'placeholder -> email)
    @inputText(pForm("password"),'_label -> "Password", '_showConstraints -> false, 'placeholder -> password)
    @inputText(pForm("phone"),'_label -> "Phone number", '_showConstraints -> false, 'placeholder -> phone)
    <input type="submit" value="edit">
}

如果用户不编辑表单,我希望表单提交电子邮件、密码、电话的当前值。我该怎么做?

【问题讨论】:

    标签: forms scala playframework playframework-2.2


    【解决方案1】:

    你可以像这样传递默认值

     @inputText(pForm("email").copy(value=Some("abc@def.com")),'_label -> "Email", '_showConstraints -> false, 'placeholder -> email)
    

    【讨论】:

    • 谢谢!我很感激。
    猜你喜欢
    • 2012-12-22
    • 2017-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-19
    • 1970-01-01
    • 1970-01-01
    • 2017-09-23
    相关资源
    最近更新 更多