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

  1. Hmm is anyone else having problems with the pictures
    on this blog loading? I’m trying to determine if
    its a problem on my end or if it’s the blog.
    Any suggestions would be greatly appreciated.

  2. With havin so much written content do you ever run into any problems of plagorism or copyright
    violation? My site has a lot of exclusive content I’ve
    either authored myself or outsourced but it appears a lot of it is
    popping it up all over the web without my agreement. Do you know any ways to help stop content from being ripped
    off? I’d truly appreciate it.

  3. It’s nnot my fiest tjme too ggo too see this site,
    i amm browxing this webb site dailly annd geet nic information from here alll
    thee time.

  4. What’s up to every single one, it’s actually a fastidious for me to pay a
    visit this web site, it includes useful Information.

  5. I have to thank you for the efforts you’ve put in writing this website.

    I’m hoping to see the same high-grade content by you later on as well.
    In truth, your creative writing abilities has motivated me to get my own blog now
    ;)

  6. Pretty great post. I simply stumbled upon your blog and wished to mention that I
    have truly loved surfing around your weblog posts. In any case
    I will be subscribing to your rss feed and I am hoping you write once more very soon!

  7. Do you mind if I quote a few of your posts as long
    as I provide credit and sources back to your website?
    My blog site is in the exact same area of interest as
    yours and my users would definitely benefit from a lot of the information you present here.

    Please let me know if this alright with you. Regards!

  8. It is effective on those in their 30s to 50s or those
    that are in the starting to observe early indications
    of aging.

  9. You have made some decent points there. I looked on the internet to find out more about
    the issue and found most people will go along with your views on this site.

  10. Great beat ! I wish to apprentice while you amend your website, how can i subscribe for a blog site?
    The account helped me a acceptable deal. I had been tiny bit acquainted of
    this your broadcast provided bright clear
    concept

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>