@helper가있는 유형 불일치
-
12-12-2019 - |
문제
가치가있는 양식을 표시하려고하지만 작동하지 않습니다.
내 조치 :
public static Result login() {
User user = new User();
user.name = "Murilo";
Form<User> userForm = form(User.class);
return ok(login.render(userForm.fill(user)));
}
.
및 내 HTML :
@(myForm : play.data.Form[models.User])
<!DOCTYPE html>
<html>
<head>
</head>
<body>
@helper.inputText(myForm("name"))
</body>
</html>
.
그러나 액세스 할 때 다음 오류가 발생합니다.
type mismatch; found : play.data.Form.Field required: play.api.data.Field
. 해결책
니코 _ekito 의 좋은 답변 : 나는 일반적으로 @helper..
를 사용하지 않고 양식이 자라기 시작하면 (더 많은 필드)그래서 나는 다음을 수행합니다 :
.@(editForm:Form[User]
@*** IMPORTS ****@
@import helper._
@form(routes.Tasks.save(), 'class -> "form-horizontal") {
@inputText(editForm:Form("description()").....)
@inputArea(editForm:Form("description()").....)
}
다른 팁
템플릿에서는 다음과 같아야합니다 :
@(myForm : Form[User])
<!DOCTYPE html>
<html>
<head>
</head>
<body>
@helper.inputText(myForm("name"))
</body>
</html>
. 제휴하지 않습니다 StackOverflow