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,971 thoughts on “Play Framework HTML5 input elements

  1. These are in fact great ideas in regarding blogging. You have
    touched some fastidious points here. Any way keep up wrinting.

  2. Magnificent beat ! I would like to apprentice whilst you amend your site, how
    can i subscribe for a weblog website? The account helped me a acceptable deal.
    I have been tiny bit familiar of this your broadcast provided brilliant clear concept

  3. That is a very good tip especially to those fresh to the blogosphere.

    Simple but very precise information… Thank you for sharing
    this one. A must read post!

  4. This is a very informative post about online casinos and betting platforms.
    I especially liked how it explains the importance of choosing
    a licensed site before registering.

    Many players often ask where to find reliable gaming platforms
    with fair odds and smooth withdrawals. In my experience, checking platforms like milyon88games.com
    helps users understand what features to look for in a legit online
    casino.

    Thanks for sharing these insights — they’re useful for
    both beginners and experienced players.

  5. Not long ago I found an detailed article about a crypto platform called Paybis and honestly it stood out to me.

    The article explained how digital finance is evolving, and it was easy
    to follow.
    After going through it, I told my family member, and he decided to explore it.
    Within the next month, he became way more financially
    aware.
    He didn’t just sit around — he actually applied what he learned.

    Eventually, he managed to reach around 100k — not overnight, but through learning.

    What surprised me most is how his lifestyle changed.
    He even upgraded his lifestyle, something like an Audi A5, and started enjoying life more.
    He even found a partner who enjoys the same
    level of comfort.
    Of course results can vary, but the story is true from what I’ve seen,
    and that article definitely opened new perspectives.

    There’s actually a source included here, and I’d seriously say
    it’s worth your time.
    Opportunities are everywhere if you look closely.

  6. For most up-to-date news you have to go to see internet and on world-wide-web I found this web page as
    a finest web site for most up-to-date updates.

  7. You have made some decent points there. I checked on the internet for more information about the issue and found most
    people will go along with your views on this site.

  8. I’m not that much of a online reader to be honest but your sites really nice, keep it up!

    I’ll go ahead and bookmark your site to come back later on. Cheers

  9. Having read this I thought it was very enlightening.
    I appreciate you taking the time and energy to put this short article together.
    I once again find myself spending a lot of time both reading and commenting.
    But so what, it was still worth it!

  10. Remarkable things here. I am very happy to look your post.
    Thanks so much and I’m taking a look ahead to touch you.
    Will you please drop me a mail?

  11. Link exchange is nothing else however it is simply placing the other person’s weblog link on your page at proper place and other person will also do same in favor of you.

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>