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.

16,068 thoughts on “Play Framework HTML5 input elements

  1. I enjoy what you guys are usually up too. This kind of clever work and coverage!

    Keep up the very good works guys I’ve incorporated you
    guys to blogroll.

  2. Hello just wanted to give you a brief heads up and let you know a few of the pictures
    aren’t loading correctly. I’m not sure why but I think its a linking issue.
    I’ve tried it in two different web browsers and
    both show the same outcome.

  3. When someone writes an post he/she keeps the plan of a user in his/her
    brain that how a user can understand it. Thus that’s why this article is perfect.
    Thanks!

  4. When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time a
    comment is added I get several emails with the same comment.

    Is there any way you can remove me from that service?
    Thanks!

  5. Hello, its fastidious post on the topic of media print,
    we all be familiar with media is a enormous source of data.

  6. Hey! I know this is kinda off topic but I was wondering which blog platform are you using for this site?

    I’m getting fed up of WordPress because I’ve had issues with hackers and I’m looking at options for another platform.
    I would be fantastic if you could point me in the direction of a
    good platform.

  7. Terrific article! That is the kind of info that are supposed to be shared around the net.

    Disgrace on the seek engines for not positioning this submit upper!

    Come on over and visit my website . Thanks =)

  8. Hi there, I wish for to subscribe for this webpage to obtain newest updates,
    therefore where can i do it please assist.

    Stop by my web page … paktoto

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>