crockpotveggies
crockpotveggies

Reputation: 13300

Play! error overloaded method value mapping with alternatives?

Defining a form in my Play! controller when the compiler spit out this weird error: overloaded method value mapping with alternative:...[a bunch of crap]...Error occurred in an application involving default arguments.

Here's the code, I'm not really sure what could be the cause:

 val jobForm: Form[Job] = Form(
    mapping(
      "id" -> of[Long],
      "end_time" -> text(minLength = 3),
      "start_time" -> text(minLength = 3),
      "client_id" -> of[Long],
      "start_address_type" -> text,
      "start_address" -> text(minLength = 3),
      "start_city" -> text(minLength = 3),
      "start_province" -> text(minLength = 2),
      "start_lat" -> optional(text),
      "start_lng" -> optional(text),
      "comments" -> text,
      "created" -> text,
      "modified" -> text,
      "canceled" -> of[Boolean],
      "started" -> of[Boolean],
      "completed" -> of[Boolean],
      "user_id" -> optional(of[Long]),
      "start_order" -> optional(number),
      "end_order" -> optional(number),
      "account_id" -> of[Long]
    )(Job.apply)(Job.unapply)
  )

Upvotes: 3

Views: 1209

Answers (1)

crockpotveggies
crockpotveggies

Reputation: 13300

Had a look at the Play! 2.0 source. Looks like you can only have 18 arguments max per mapping() so I had to start nesting and create new case classes. Here's the result:

val jobForm: Form[JobSimple] = Form(
    mapping(
      "id" -> of[Long],
      "end_time" -> text(minLength = 3),
      "start_time" -> text(minLength = 3),
      "client_id" -> of[Long],
      "location" -> mapping(
        "start_address_type" -> text,
        "start_address" -> text(minLength = 3),
        "start_city" -> text(minLength = 3),
        "start_province" -> text(minLength = 2),
        "start_lat" -> optional(text),
        "start_lng" -> optional(text)
        )(JobLocation.apply)(JobLocation.unapply),
      "comments" -> text,
      "created" -> text,
      "modified" -> text,
      "canceled" -> of[Boolean],
      "started" -> of[Boolean],
      "completed" -> of[Boolean],
      "user_id" -> optional(of[Long]),
      "start_order" -> optional(number),
      "account_id" -> of[Long]
    )(JobSimple.apply)(JobSimple.unapply)
  )

Upvotes: 4

Related Questions