Play 2.2 Scala:简单表单的默认值

时间:2014-04-24 00:05:03

标签: forms scala playframework playframework-2.2

目前,我有一个简单的表单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">
}

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

1 个答案:

答案 0 :(得分:2)

您可以传递默认值,如

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