为什么Play拒绝表单报告"无法解决方法适用于此类签名:缺少参数"?

时间:2014-12-29 13:26:46

标签: scala playframework

我有一个非常广泛的形式定义为;

case class EditDetail(token: String,
                      placeId: Long,

                      // accessibility
                      privateParking: Option[Boolean],
                      privateParkingType: Option[Int], // 0: internal, 1: external, 3: street
                      bikeParking: Option[Boolean],
                      valetService: Option[Boolean],
                      wheelChairAccess: Option[Boolean],

                      //  facilities
                      cashOnly: Option[Boolean],
                      paymentMeans: Option[List[String]], // comma separated Option[List[String]]s
                      wifi: Option[Int],
                      smoking: Option[Boolean],
                      aircon: Option[Boolean],

                      //  dining
                      dietaryRestrictions: Option[List[String]],
                      mealsServed: Option[List[String]],
                      alcoholChoice: Option[List[String]],
                      outdoorSeating: Option[Boolean],
                      catering: Option[Boolean],

                      //  reservation
                      acceptsReservations: Option[Int] /*, // 0: no, 1: yes, 2: only groups
                           reservationMethods: Option[List[String]], // <-- the problem area
                           reservationUrl: Option[String],
                           groupSizeMin: Option[Int],
                           groupSizeMax: Option[Int],

                           //  delivery & takeaway
                           delivery: Option[Boolean],
                           minDeliveryAmt: Option[BigDecimal],
                           takeAway: Option[Boolean],

                           // atomosphere
                            musicType: Option[List[String]],
                            ambiance: Option[List[String]],
                            attire: Option[List[String]],
                            surrounding: Option[List[String]],
                            viewPoint: Option[Boolean],
                            goodForKids: Option[Boolean],
                            tv: Option[Boolean],
                            sportsFeatured: Option[List[String]]*/) {
  var place: Place = _
  var user: User = _
}

var editDetailForm = Form(
  mapping(
    "token" -> nonEmptyText,
    "place_id" -> longNumber,
    /*ACCESSIBILITY*/
    "private_parking" -> optional(boolean),
    "private_parking_type" -> optional(number(0, 3)),
    "bike_parking" -> optional(boolean),
    "valet_service" -> optional(boolean),
    "wheelchair_access" -> optional(boolean),
    /*FACILITIES*/
    "cash_only" -> optional(boolean),
    "payment_means" -> optional(list(text)),
    "wifi" -> optional(number(0, 2)),
    "smoking" -> optional(boolean),
    "aircon" -> optional(boolean),
    //    /*DINING OPTIONS*/
    "dietary_restrictions" -> optional(list(text)),
    "meals_served" -> optional(list(text)),
    "alcohol_choice" -> optional(list(text)),
    "outdoor_seating" -> optional(boolean),
    "catering" -> optional(boolean),
    /*RESERVATIONS*/
    "accepts_reservations" -> optional(number)
    //    "reservation_methods" -> optional(list(text)) // <-- problem area
    //    "reservation_url" -> optional(text),
    //    "group_size_min" -> optional(number(0)),
    //    "group_size_max" -> optional(number(0)),
    //    /*DELIVERY & TAKEAWAY*/
    //    "delivery" -> optional(boolean),
    //    "min_delivery_amount" -> optional(bigDecimal),
    //    "takeaway" -> optional(boolean),
    //    /*ATMOSPHERE*/
    //    "music_type" -> optional(list(text)),
    //    "ambiance" -> optional(list(text)),
    //    "attire" -> optional(list(text)),
    //    "surrounding" -> optional(list(text)),
    //    "view_point" -> optional(boolean),
    //    "good_for_kids" -> optional(boolean),
    //    "tv" -> optional(boolean),
    //    "sports_featured" -> optional(list(text))
  )(EditDetail.apply)(EditDetail.unapply))

如果您看到上面的代码并看到标有<-- problem area的行,如果我在EditDetaileditDetailForm中取消注释该行,我就会知道:

  

无法解析使用此类签名的方法:缺少参数

为什么?

1 个答案:

答案 0 :(得分:7)

那是因为你超过了单个元组的最大字段数(18),这是Play doc所说的:

  

注意:单个元组或映射的最大字段数为18   实现表单处理的方式。如果你有超过18   您的表单中的字段,您应该使用列表或分解您的表单   嵌套值。