0
두 개의 간단한 엔티티가 있습니다. 하나는 고객은이고 기본 문자열은 customerName이고 사용자는이며 전자 메일, 암호 및 고객과의 관계가 있습니다.Play Framework 및 combobox
사용자가 한 명이므로 필수입니다. 내보기에 전달하는 하나의 양식이 있습니다.
static Form<User> formUser = Form.form(User.class);
...
...
return ok(views.html.user.index.render(formUser, Customer.find.all()));
제 생각에는 양식 도우미를 사용합니다. 예를 들어 는 :
@helper.form(routes.Users.newUser()) {
@inputText(userForm("email"))
@select(
field = userForm("customer"),
customers.map{ c =>
c.id.toString -> c.customerName
},
args = '_label -> "Customer"
)
<input type="submit" value="New" />
}
하지만 내 POST 방법에
, 내가 고객 필드에 대한 "잘못된 값"으로, 내 bindFromRequest상의 오류을 얻었다.Form<User> filledForm = formUser.bindFromRequest();
if (filledForm.hasErrors()) {
return badRequest(views.html.user.index.render(filledForm, Customer.find.all()));
}
User user = filledForm.get()
사용자 클래스의 필드를 게시 할 수 있습니까? – lassejl