我在使用表单助手时遇到了问题。我想在将表单传递给视图之前向表单添加一个错误,但出现以下错误:
value withGlobalError is not a member of play.api.data.Form[(String, String)]
我的代码如下:
def loginForm = Form(
tuple (
"email" -> nonEmptyText,
"password" -> nonEmptyText
)
)
def asignIn = Action {
implicit request =>
loginForm.bindFromRequest.fold (
formWithErrors => Ok(views.html.login(formWithErrors.withGlobalError("Invalid username or password")),
user => authenticationStep(user)(request)
)
}