Play Framework HTML5 input elements

The built in Play input elements are fairly restrictive in that you can’t specify the input type. I wrote a helper template that you can use to generate input elements which have HTML5 type attributes such as url, email, number, search etc. etc.

All you have to do is call the template method, passing the HTML input type as a parameter. For example:

@helper.html5.input(form("website"), '_label -> "Website:", 'type -> "url")

If you have a form field mapped as a play.api.data.Forms.email then the template will automatically infer it’s type so you don’t have to pass the type attribute in with your html attributes:

@helper.html5.input(form("email"), '_label -> "Email:")

If your field has the required constraint, e.g. it is a “nonEmptyText” then the template will add the HTML5 “required” attribute to the field as well.

You can get the source code here.

14,911 thoughts on “Play Framework HTML5 input elements

  1. We are a gaggle of volunteers and opening a new scheme in our
    community. Your site provided us with valuable info to work on. You’ve done a formidable
    activity and our whole neighborhood might be grateful to you.

  2. I have been surfing online more than 4 hours today,
    yet I never found any interesting article
    like yours. It’s pretty worth enough for me.

    Personally, if all webmasters and bloggers made good content as you did, the web will be much more useful than ever before.

    my webpage … best realtor in Tampa FL

  3. Hi it’s me, I am also visiting this website regularly, this web page is in fact nice
    and the users are in fact sharing fastidious thoughts.

  4. You really make it seem really easy with your presentation but I in finding this
    matter to be actually something that I feel I might never understand.
    It sort of feels too complex and very extensive for me.
    I am looking ahead for your next submit, I will try to get the
    grasp of it!

    Here is my webpage real estate agent Carlsbad CA

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>