Generating forms
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, ...
Get Mastering Play Framework for Scala now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.