O'Reilly logo

Mastering Play Framework for Scala by Shiti Saxena

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required