播放(Scala)表单验证错误

时间:2014-04-15 03:50:34

标签: validation scala playframework

我想在Play(Scala)中进行表单验证,我已经多次这样做但是这次它显示错误..错误说:

  

无法应用重载方法值[apply]   (play.api.data.Mapping [models.PIdetail])

型号:

package models

import java.util.Date
import play.api.libs.json._
import play.api.libs.functional.syntax._
import anorm._
import anorm.SqlParser._
import play.api.db.DB
import play.api.Play.current
import models._
case class Purchase_Invoice(supplier_id: String, paid_to_num: String, staff_id: String, paid_to_name: String, staff_name: String, paid_to_addr: String, PI_date: Date, PI_due_date: Date, payment: String, purchase_invoice_items: List[PIdetail], other: String, additional_note: String, terms_and_cond: String)
case class PIdetail(RI_id: Int, PO_id: String, product_id: String, description: String, qty: Int, total: String)
case class RIheader_PI(id_counter: Long, date_RI: Date, staff_id: String, status: Int)

控制器:

package controllers

import play.api._
import play.api.Logger
import play.api.mvc._
import play.api.data._
import play.api.data.Forms._
import play.api.data.format.Formats._
import play.api.mvc.Flash
import play.api.libs.json.Json
import play.api.libs.json._
import models._
object PurchaseInvoices extends Controller {
    val submitPIForm = Form(
        mapping(
            "supplier_id" -> text,
            "paid_to_num" -> text,
            "staff_id" -> text,
            "paid_to_name" -> text,
            "staff_name" -> text,
            "paid_to_addr" -> text,
            "PI_date" -> date,
            "PI_due_date" -> date,
            "payment" -> text,
            "purchase_invoice_items" -> list(
                mapping(
                    "RI_id" -> number,
                    "PO_id" -> text,
                    "product_id" -> text,
                    "description" -> text,
                    "qty" -> number,
                    "total" -> text
                )(PIdetail.apply)(PIdetail.unapply)
            ),
            "other" -> text,
            "additional_note" -> text,
            "terms_and_cond" -> text
        )(Purchase_Invoice.apply)(Purchase_Invoice.unapply)
    )
...................... Some codes
...................... Some codes
}

真的需要你的帮助..感谢之前...... ^^

1 个答案:

答案 0 :(得分:1)

自己发现错误.. ^^
这是因为我的控制器中有def list = TODO 因此,请确保您没有使用scala函数定义具有相同名称的函数/变量。

抱歉打扰你们...... thx .. ^^