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.

7,660 thoughts on “Play Framework HTML5 input elements

  1. Valuable info. Lucky me I discovered your web site by chance, and I am stunned why this coincidence
    did not came about in advance! I bookmarked it.

  2. Great work! This is the type of info that are
    meant to be shared across the web. Disgrace on the search engines for no longer positioning this publish higher!
    Come on over and consult with my site . Thank you
    =)

  3. Курьер нашёл дверь сразу. Сервис супер доставка цветов

  4. Spot on with this write-up, I absolutely feel this website needs a great deal more attention. I’ll probably be
    returning to read more, thanks for the info!

  5. Looking back now, it feels surreal but here I am.

    Not long ago, I got way too invested in online games – CS:GO.
    I wanted instant results, and I didn’t want to rely on skill alone.

    Late one night, I stumbled across a forum thread talking about “boosting tools”.
    At first I just read out of curiosity, but the deeper I went into the thread, the more it felt like a secret
    world.

    People were bragging showing how they climbed from low ranks to high
    ones in days. It looked like magic. And of course, the downside was completely hidden.

    To be honest, I actually got close to buying something.
    One guy tried to explain the “features” to me. That’s when things turned dark.

    I found threads from players who got hardware bans.

    Some even wrote how their bank info got stolen. That was my wake-up call.

    Instead of throwing everything away, I deleted the messages and focused on improving the legitimate way.

    Now, when I see people chasing cheats, I just
    think: you risk everything for nothing. Just learn from my almost-mistake.

  6. Hi, There’s no doubt that your web site might be having web browser compatibility issues.

    Whenever I take a look at your web site in Safari, it looks fine however, when opening in I.E., it’s got some overlapping issues.
    I just wanted to provide you with a quick heads up! Other than that, fantastic site!

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>