John
John

Reputation: 5344

List in form outputs weird error in Play 2.1.3

I've been struggling with the following ..

I have the two case class:

case class Entry_form(name: String, date: Date, debit: List[Entry_account])
case class Entry_account(amount: Double, account: Long)

and the associated form

val myForm = Form(
        mapping(
            "name"                      -> nonEmptyText,
            "date"                      -> date("dd.MM.yyyy"),
            "debit"                     -> list(mapping(
                    "amount"            -> of[Double],
                    "account"       -> longNumber
                )(Entry_account.apply)(Entry_account.unapply))
        )
        (Entry_form.apply)(Entry_form.unapply)
    )

And I get the following error:

type mismatch;
[error]  found   : play.api.data.Mapping[models.Entry_account]
[error]  required: play.api.mvc.RequestHeader
[error]                 )(Entry_account.apply)(Entry_account.unapply))
[error]                                       ^
[error] one error found
[error] (compile:compile) Compilation failed

can somebody help me out? Thank you

Upvotes: 1

Views: 73

Answers (1)

Shrey
Shrey

Reputation: 2404

Easy. Import the following!

import play.api.data.format.Formats._

Update

To avoid the conflict between libraries, you can create aliases

import play.api.data.format.Formats.{doubleFormat => someSpecificName}

Upvotes: 2

Related Questions