1

我一直在努力解决以下问题..

我有两个案例类:

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

和相关的表格

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)
    )

我收到以下错误:

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

有人可以帮帮我吗?谢谢

4

1 回答 1

2

简单的。导入以下!

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

更新

为了避免库之间的冲突,您可以创建别名

import play.api.data.format.Formats.{doubleFormat => someSpecificName}
于 2013-10-06T07:34:13.907 回答