Forms are important in situations where the application requires input from users, for example, in the case of registration, login, search, and so on.
Play provides helpers to generate a form and wrapper classes to translate the form data into a Scala object.
Now, we'll build a user registration form using the form helper provided by Play:
@helper.form(action = routes.Application.newUser) { <label>Email Id <input type="email" name="email" tabindex="1" required="required"> </label> <label>Password <input type="password" name="password" tabindex="2" required="required"> </label> <input type="submit" value="Register" type="button"> }
Here, @helper.form
is a template provided by Play, which is defined as follows:
@(action: play.api.mvc.Call, args: (Symbol,String)*)(body: => Html) <form action="@action.url" method="@action.method" @toHtmlArgs(args.toMap)> @body </form>
We...