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.

20,558 thoughts on “Play Framework HTML5 input elements

  1. Have you ever considered about including a little bit
    more than just your articles? I mean, what you say is important and all.
    Nevertheless just imagine if you added some great graphics
    or videos to give your posts more, “pop”! Your content
    is excellent but with images and clips, this site could certainly
    be one of the very best in its niche. Very good blog!

  2. This is really attention-grabbing, You’re a very professional blogger.
    I have joined your feed and look ahead to searching for more of your
    great post. Also, I have shared your web site in my social
    networks

  3. Hello there, There’s no doubt that your blog could possibly be having internet browser compatibility problems.

    When I take a look at your blog in Safari, it looks fine however, when opening
    in IE, it’s got some overlapping issues. I simply
    wanted to provide you with a quick heads up! Besides that, wonderful blog!

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

    Many players often ask where they can find reliable gaming
    platforms with fair odds and smooth payouts. From what I’ve
    seen, checking platforms like vn22vip helps users compare features,
    bonuses, and overall experience.

    Thanks for sharing these insights — they’re helpful for both beginners and experienced bettors.

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>