0

フォーム ヘルパーで問題が発生しています。ビューに渡す前にフォームにエラーを追加したいのですが、次のエラーが発生します。

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)
      )
    }
4

1 に答える 1

1

電子メールとパスワードの確認は、次のような形式で行う必要があります。

val loginForm = Form(
  tuple(
    "email" -> nonEmptyText,
    "password" -> text
  ) verifying("Invalid user name or password", fields => fields match { 
      case (email, pwd) => User.authenticate(email,pwd).isDefined 
  })
)
于 2012-10-23T10:44:55.677 に答える