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

  1. Hi! I could hav worn I’ve beeen tto this weebsite efore but after reaading throuhgh somje
    off the posst I realized it’s neew too me. Anyhow, I’m dwfinitely hapy I fund itt annd I’ll be book-marking
    andd checking back frequently!

  2. Now I am ready to do my breakfast, later than having my breakfast coming yet again to read further news.

  3. When it pertains to divorce mediation prices, it is necessary to recognize what
    to expect.

  4. With havin so much written content do you ever run into any problems
    of plagorism or copyright infringement? My blog has a lot of exclusive content I’ve
    either created myself or outsourced but it appears a lot of it is
    popping it up all over the web without my permission. Do you know any ways
    to help prevent content from being stolen? I’d
    definitely appreciate it.

  5. Hi there! Someone in my Myspace group shared this website with us so I came to look it over.

    I’m definitely enjoying the information. I’m book-marking
    and will be tweeting this to my followers! Great blog and fantastic design and
    style.

  6. Dubai is song of the world’s outstrip real estate investment destinations, sacrifice
    dues advantages, energetic rental yields, and премиум
    lifestyle opportunities. From sybaritism villas to high-rise apartments, buying
    chattels in Dubai provides unequalled passive for both income and long-term
    top growth.

  7. It is perfect time to make some plans for the longer
    term and it’s time to be happy. I have read this put up and if I could I wish to counsel you few
    attention-grabbing things or advice. Maybe you can write subsequent articles regarding this article.
    I desire to learn even more issues about it!

  8. Hello would you mind stating which blog platform
    you’re working with? I’m looking to start my own blog
    in the near future but I’m having a difficult time choosing between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your layout seems different then most blogs and
    I’m looking for something completely unique.
    P.S Apologies for getting off-topic but I had to ask!

    Also visit my web blog – serviço iptv portugal

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>