Play framework 2.2.x中定义的parse.form方法?

时间:2017-01-14 17:30:47

标签: scala playframework

播放文档提到了parse.form方法,该方法可用于绑定到传入的请求。我正在使用play 2.2.x.此版本中是否定义了此方法?我收到编译错误

value form is not a member of object controllers.Application.parse

def regSubmit = Action(parse.form(userForm) { implicit request =>
    val userData= request.body
    Ok(views.html.regconf("Registration Successful")(userForm.fill(userData)))

  })

1 个答案:

答案 0 :(得分:0)

据我所知2.2.x source code,parse.form当时不存在,只在2.4.x中引入。

有什么理由不使用“等效”bindFromRequest并处理可能存在的错误?沿着:

def regSubmit = Action { implicit request =>
  userForm.bindFromRequest.fold (
    errors => //-- 'errors' is a form with FormErrors set
      Ok(views.html.register(errors)) //-- register is the initial form
    userData => //-- 'userData' is the case class that userForm maps to
      Ok(views.html.regconf("Registration Successful")(userForm.fill(userData)))
  )
}

我没有检查源代码,看它是否在2.2.x中。没有提到文档的on the ScalaForms page