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

  1. GSC108 merupakan platform digital yang menjadi tempat
    perkumpulan para pecinta kucing seluruh Indonesia, Di platform ini kamu dapat berbagi
    pengalaman maupun menanyakan permasalahan yang kamu
    alami dan membutuhkan solusi yang tepat karena terdapat teman teman sesama pecinta
    kucing yang telah berpengalaman

  2. Whoa! This blog looks just like my old one! It’s on a
    completely different subject but it has pretty much the same page layout and design. Great choice of colors!

  3. I never thought I’d end up writing this but here I am.

    Back when the new competitive season started, I got way too invested in online games – Dota 2.

    I wanted instant results, and I wasn’t willing to admit how impatient I
    had become.

    One evening, I stumbled across a forum thread talking about scripts.
    At first I laughed it off, but the more I scrolled, the more it felt like
    a tempting escape.

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

    Truth be told, I actually got close to buying something.
    Someone pushed a “limited offer” in my
    inbox. That’s when the real consequences showed up.

    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 cheating, I walked away and focused on improving the legitimate way.

    Now, when I see people chasing cheats, I just think: you risk everything for nothing.
    Hopefully this story saves someone else time.

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>