【发布时间】:2014-02-03 15:59:12
【问题描述】:
我已经实现了这个表单
val contactForm : Form[Contact] = Form(
mapping(
"id" -> ignored(NotAssigned: anorm.Pk[Long]),
"fax" -> longNumber,
"person" ->nonEmptyText,
"mobilePhone" -> longNumber,
"phone" -> longNumber,
"email" -> nonEmptyText,
"supplierId"-> mapping(
"id" -> ignored(NotAssigned: anorm.Pk[Long]),
"identityId" -> mapping(
"id" -> ignored(NotAssigned: anorm.Pk[Long]),
"codiceFornitore" -> number,
"supplierType" -> nonEmptyText,
"ragioneSociale" -> nonEmptyText,
"partitaIva" -> longNumber,
"isProduction" -> boolean //act as boolean 0=FALSE
)(SupplierIdentity.apply)(SupplierIdentity.unapply),
"addressId" -> mapping(
"id" -> ignored(NotAssigned: anorm.Pk[Long]),
"via" -> nonEmptyText,
"cap" -> number,
"comune" -> nonEmptyText,
"provincia" -> nonEmptyText,
"paese" -> nonEmptyText
)(Address.apply)(Address.unapply),
"userId" -> mapping(
"id" -> ignored(NotAssigned: anorm.Pk[Long]),
"name" -> nonEmptyText
)(User.apply)(User.unapply))
(Supplier.apply)(Supplier.unapply)
)(Contact.apply)(Contact.unapply)
)`
Contact、SupplierIdentity、Supplier、Address 和 User 是 Case Class。 这是我的模板
@(supplier: Supplier, contactForm : Form[Contact])
.
.
.
@form(routes.FinanceController.addContact(supplier.id.get)) {
@helper.input(contactForm("fax"), '_id -> "fax", '_label->"Fax" , '_error -> contactForm.error("fax")) { (id, name, value, args) =>
<input type="text" id="@id" name="@name" value="" @toHtmlArgs(args)>
}
@helper.input(contactForm("person"), '_id -> "person", '_label->"Figura di Riferiment", '_error -> contactForm.error("person")) { (id, name, value, args) =>
<input type="text" id="@id" name="@name" value="" @toHtmlArgs(args)>
}
@helper.input(contactForm("mobilePhone"), '_id -> "mobilePhone", '_label->"Cellulare", '_error -> contactForm.error("mobilePhone")) { (id, name, value, args) =>
<input type="text" id="@id" name="@name" value="" @toHtmlArgs(args)>
}
@helper.input(contactForm("phone"), '_id -> "phone", '_label->"Cellulare", '_error -> contactForm.error("phone")) { (id, name, value, args) =>
<input type="text" id="@id" name="@name" value="" @toHtmlArgs(args)>
}
@helper.input(contactForm("email"), '_id -> "email", '_label->"E-mail", '_error -> contactForm.error("email")) { (id, name, value, args) =>
<input type="text" id="@id" name="@name" value="" @toHtmlArgs(args)>
}
@helper.input(contactForm("supplierId"), '_id -> "supplierId", '_error -> contactForm.error("supplierId")) { (id, name, value, args) =>
<input type="hidden" id="@id" name="@name" value="@{supplier}" @toHtmlArgs(args)>
}
<input type="submit" value="Create">
}
但是当我尝试使用它时,我得到了这个错误:
List(FormError(supplierId.identityId.codiceFornitore,error.required,List()), FormError(supplierId.identityId.supplierType,error.required,List()), FormError(supplierId.identityId.ragioneSociale,error.required,List()), FormError(supplierId.identityId.partitaIva,error.required,List()), FormError(supplierId.addressId.via,error.required,List()), FormError(supplierId.addressId.cap,error.required,List()), FormError(supplierId.addressId.comune,error.required,List()), FormError(supplierId.addressId.provincia,error.required,List()), FormError(supplierId.addressId.paese,error.required,List()), FormError(supplierId.userId.name,error.required,List()))
我真的陷入了这个错误,我无法找到错误在哪里,我没有任何列表!
谢谢。
【问题讨论】: