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.

22,060 thoughts on “Play Framework HTML5 input elements

  1. Hey there are using WordPress for your blog platform?

    I’m new to the blog world but I’m trying to get started and create my own. Do you need any
    html coding expertise to make your own blog?
    Any help would be greatly appreciated!

  2. Hmm is anyone else experiencing problems with the pictures on this blog loading?
    I’m trying to find out if its a problem on my end or if it’s the
    blog. Any responses would be greatly appreciated.

  3. My spouse and I stumbled over here different web page and thought
    I might check things out. I like what I see so now i am following you.
    Look forward to looking at your web page repeatedly.

  4. I am really impressed with your writing talents as well as with the layout to your blog.
    Is that this a paid theme or did you modify it yourself? Either way stay up the nice high
    quality writing, it’s uncommon to see a great blog like this
    one today..

    my page – electric bike for adults

  5. Hi, i think that i saw you visited my site so i came to
    “return the favor”.I am trying to find things to improve my website!I suppose its ok to use some of your ideas!!

  6. I simply couldn’t leave your website before suggesting that I actually loved the standard information an individual supply to your guests?
    Is gonna be again steadily to inspect new posts

  7. Whoa! This blog looks exactly like my old one!

    It’s on a entirely different topic but it has pretty much the same page layout
    and design. Great choice of colors!

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>