Reputation: 15593
I'm trying to show a form with the values but it's not working.
my action:
public static Result login() {
User user = new User();
user.name = "Murilo";
Form<User> userForm = form(User.class);
return ok(login.render(userForm.fill(user)));
}
and my html:
@(myForm : play.data.Form[models.User])
<!DOCTYPE html>
<html>
<head>
</head>
<body>
@helper.inputText(myForm("name"))
</body>
</html>
but when I access it, the following error throws:
type mismatch; found : play.data.Form.Field required: play.api.data.Field
Upvotes: 2
Views: 1552
Reputation: 5951
As a addition to nico_ekito's good answer: I usually do not use @helper..
because it is long and not/less readable if your form starts to grow (more fields). So I do the following:
@(editForm:Form[User]
@*** IMPORTS ****@
@import helper._
@form(routes.Tasks.save(), 'class -> "form-horizontal") {
@inputText(editForm:Form("description()").....)
@inputArea(editForm:Form("description()").....)
}
Upvotes: 3
Reputation: 21564
In your template, it should be:
@(myForm : Form[User])
<!DOCTYPE html>
<html>
<head>
</head>
<body>
@helper.inputText(myForm("name"))
</body>
</html>
Upvotes: 3