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

  1. Thank you for any other fantastic article. Where else could
    anybody get that kind of info in such a perfect method of writing?
    I’ve a presentation next week, and I’m at the search for such
    information.

  2. Hmm is anyone else having problems with the images on this
    blog loading? I’m trying to find out if its a problem on my end or if it’s the blog.
    Any responses would be greatly appreciated.

  3. hello there and thank you for your information – I’ve definitely
    picked up anything new from right here. I did however
    expertise several technical issues using this site, as I experienced to reload the site a lot
    of times previous to I could get it to load correctly.
    I had been wondering if your web hosting is OK?
    Not that I’m complaining, but sluggish loading instances times will often affect your placement in google and can damage your quality score if advertising and
    marketing with Adwords. Well I’m adding this RSS to my email and can look out
    for a lot more of your respective exciting content.
    Ensure that you update this again soon.

  4. Hello There. I found your blog using msn. This is an extremely
    well written article. I will make sure to bookmark it and come back to read more of your useful info.
    Thanks for the post. I will certainly comeback.

  5. Keep savvy witһ Kaizenaire.cоm, Singapore’ѕ leading collector ᧐f deals, promotions, аnd shopping events.

    Ԝith deluxe brand names ɑnd street delays alike,
    Singapore іs а shopping heaven wһere promotions maintain deal-hungry Singaporeans returning.

    Singaporeans ⅼike joining flash mobs in public rօoms for spontaneous fun, and remember t᧐ stay updated օn Singapore’ѕ most current
    promotions and shopping deals.

    Οrder giveѕ ride-hailing, food shipment,
    ɑnd financial services, loved ƅy Singaporeans for their ease іn ԁay-to-ⅾay commutes and dishes.

    Tһe Closet Lover рrovides cost effective stylish clothing օne, preferred by budget-conscious fashionistas іn Singapore foг theiг frequent updates mah.

    Еach Ꭺ Cup appeases with budget-friendly bubble teas ɑnd juices, cherished ƅy budget-conscious
    citizens fߋr fast, flavorful pick-mе-ups.

    Eh, why not lah, Singaporeans neeɗ to inspect Kaizenaire.com everyday mah.

    Ηere iѕ my site … promo

  6. Hello every one, here every one is sharing these kinds of experience, therefore it’s good to
    read this blog, and I used to go to see this website daily.

    Here is my homepage achat d’or

  7. Pretty nice post. I just stumbled upon your weblog
    and wished to say that I have truly enjoyed surfing around your blog posts.
    In any case I will be subscribing to your rss feed and I hope you write
    again very soon!

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>