我有一個窗體的問題,問題是我無法正確顯示錯誤(我認爲是這樣)。驗證工作正常。玩框架2.0 scala窗體錯誤處理
當舊密碼不正確時另一方面,當密碼不匹配時,錯誤消息顯示在輸入框下方,錯誤不會出現在任何地方。從視圖
:
如果我做一些調試,我得到的數據 @pass_form("password").errors
我得到這個:
FormError(password,Passwords dont match,WrappedArray())
所以我的問題是如何解決的形式或代碼視圖,正確打印該錯誤。
Form(
mapping(
"old_password" -> text.verifying(Messages("forms.password.old.mismatch"),
password => User.correct_?(user.id, password)),
"password" -> tuple(
"new" -> text(minLength = conf.getInt("password.length.min").get),
"confirm" -> text).verifying(Messages("forms.password.new.mismatch"),
passwords => passwords._1 == passwords._2)
)
((_, password) => password._1)((_) => Some(("", ("", ""))))
)
鑑於我:
@helper.form(action = routes.UserController.submitPassword) {
@helper.input(pass_form("old_password")) { (id, name, value, args) =>
<input type="password" name="@name" id="@id" @toHtmlArgs(args)>
}
@helper.input(pass_form("password.new")) { (id, name, value, args) =>
<input type="password" name="@name" id="@id" @toHtmlArgs(args)>
}
@helper.input(pass_form("password.confirm")) { (id, name, value, args) =>
<input type="password" name="@name" id="@id" @toHtmlArgs(args)>
}
<input type="submit" value="Set">
}
它可能是一個轉儲的問題,而是你如何讓你的形式'user.id'? –
我使用https://github.com/t2v/play20-auth中的模塊,並且有一個名爲authorizedAction的方法,它給了我一個用戶。 – mapek
謝謝,我會檢查。 –