Използвам Play 2.0 със Scala и бих искал да извлека някои стойности, които се съхраняват в скрити полета.
Формулярът в контролера:
val recommendationForm: Form[Recommendation] = Form(
mapping(
"fromMail" -> email,
"fromName" -> nonEmptyText(5, 30),
"toMail" -> email,
"toName" -> nonEmptyText(5, 30),
"message" -> optional(text(0, 300)),
"productGroupId" -> nonEmptyText(),
"masterProductId" -> nonEmptyText()
)
(Recommendation.apply)(Recommendation.unapply)
)
def doRecommend = xyzAction { implicit request =>
recommendationForm.bindFromRequest.fold(
errors => {
errors.data.map(x => println(x))
BadRequest("")
},
{
case (recommendation) => {
Ok("")
}
}
)
}
Класът за препоръка:
case class Recommendation(fromMail: String, fromName: String, toMail: String, toName: String, message: Option[String], productGroupId: String, masterProductId: String)
HTML:
@form(action = routes.Product.doRecommend) {
<input type="hidden" value="@{(productGroup \ "@id").text}" />
<input type="hidden" value="@{(currentMasterProduct \ "@id").text}" />
@inputText(field = recommendationForm("fromName"),
'_label -> "",
'placeholder -> Messages("recommendation.from.name"),
'_showConstraints -> false,
'class -> "text ui-widget-content ui-corner-all"
)
some more fields...
}
Генериран HTML на скрито поле:
<input type="hidden" value="74.75.652">
Но не мога да извлека тези две скрити полета от грешките. Той отпечатва само останалите пет. Как мога да извлека скритите?