Bla...
Bla...

Reputation: 7288

Play (Scala) form validation error

I want to make a form validation in Play (Scala), I have done this several times but this time it shows error.. The error says:

Overloaded method value [apply] cannot be applied to (play.api.data.Mapping[models.PIdetail])

Model:

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)

Controller:

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
}

really need your help guys.. thanks before.. ^^

Upvotes: 1

Views: 442

Answers (1)

Bla...
Bla...

Reputation: 7288

Found out the error by myself.. ^^
It's because I have def list = TODO in my Controller..
So make sure you don't define a function/variable that has the same name with scala function..

Sorry to bother you guys... thx.. ^^

Upvotes: 1

Related Questions