val computerForm = Form(
mapping(
"id" -> ignored(NotAssigned:Pk[Long]),
"name" -> nonEmptyText,
"introduced" -> optional(date("yyyy-MM-dd")),
"discontinued" -> optional(date("yyyy-MM-dd")),
"company" -> optional(longNumber)
)(Computer.apply)(Computer.unapply)
)
this code giving me the error too many arguments for method mapping:
(apply: (String, String, String) => R)(unapply: R => Option[(String, String, String)])play.api.data.Mapping[R]..please solve this issue"
Let's go in order, from Play2 Scaladoc. The Form method you are calling is
Form.applyForm scaladoc
so your mapping(smth) should return a
(String,Mapping[T]). The mapping method is instead defined in the objectFormsForms Scaladoc
Forms.mapping is an overloaded method with multiple available signatures, let's look at one
So this method takes a first list of parameters
(a1,a2,a3,a4)each of type(String,Mapping[Aindex]), one another list of parameter containing a single parameterapply: (A1, A2, A3, A4) ⇒ R, and a last parameter list containing a single parameterunapply: (R) ⇒ Option[(A1, A2, A3, A4)]In general, for all overloaded version of mapping, the signature impose such that apply / unapply should have the signature corresponding a tupled version of the first list of parameter.
What is happening here, is that through
->you are creating 5(String,Mappings[Asomething])tuples, while yourapply/unapplyhas only 3 arguments