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.

13,847 thoughts on “Play Framework HTML5 input elements

  1. After going over a handful of the articles on your blog, I truly
    appreciate your technique of blogging. I added it to my bookmark website list and will be checking back
    in the near future. Please check out my website too and tell me what you think.

  2. Hey! I’m at work browsing your blog from my new iphone!
    Just wanted to say I love reading your blog and look forward to all your posts!
    Keep up the outstanding work!

  3. Hi are using WordPress for your site platform? I’m new to the blog world but I’m trying
    to get started and create my own. Do you require any html coding knowledge
    to make your own blog? Any help would be greatly appreciated!

  4. lanciao
    Nice blog here! Also your website loads up fast! What web host are
    you using? Can I get your affiliate link to your host? I wish my site loaded up as fast as yours lol

  5. Today, I went to the beachfront with my children. I found a
    sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She placed the shell to
    her ear and screamed. There was a hermit crab inside and it pinched her ear.
    She never wants to go back! LoL I know this is totally off topic but I had
    to tell someone!

  6. Open thе vеry bеst of Singapore’ѕ shopping at Kaizenaire.ϲom, the top website fоr promotions аnd
    deals.

    Singaporeans light uρ with promotions, symbolizing tһe
    spirit of Singapore as the region’s premier shopping paradise.

    Singaporeans commonly unwind ѡith family outings
    аt East Coast Park, ɑnd remember tߋ remain upgraded оn Singapore’ѕ latest promotions ɑnd shopping deals.

    Jardine Cycle & Carriage deals іn vehicle sales and solutions, valued by Singaporeans for their premium cars аnd truck brands and reliable ɑfter-sales sustain.

    Masion, ⅼikely a fashion tɑg lah, offers sophisticated clothing lor, cherished Ьу stylish
    Singaporeans fоr theіr refined designs leh.

    Tian Tian Hainanese Chicken Rice draws ɡroups f᧐r silky chicken and greаt
    smelling rice, valued Ьу Singaporeans foг
    its straightforward yеt superb local flavors.

    Eh, smart Singaporeans mah, visit Kaizenaire.com constantly lah.

    Feel free to surf to my website … uob promotions (https://ematixglo.com/check-out-cold-storage-supermarket-promotions-and-deals-in-singapore-on-kaizenaire-com/)

  7. Hi there! I could have sworn I’ve visited
    your blog before but after going through a few of the articles
    I realized it’s new to me. Anyhow, I’m certainly delighted
    I discovered it and I’ll be bookmarking it
    and checking back often!

  8. I’ve learn a few excellent stuff here. Certainly price bookmarking for revisiting.

    I surprise how much attempt you set to make the sort
    of fantastic informative website.

  9. I wanted to thank you for this fantastic read!!
    I certainly loved every little bit of it.
    I’ve got you book-marked to check out new stuff you post…

  10. I’m amazed, I must say. Rarely do I encounter
    a blog that’s both educative and entertaining, and without a doubt, you’ve
    hit the nail on the head. The problem is something that not enough men and women are speaking intelligently about.
    I am very happy that I came across this in my hunt for something relating
    to this.

  11. I visited many sites however the audio quality for audio songs
    existing at this web site is genuinely fabulous.

  12. I’m extremely impressed with your writing skills and also with
    the layout on your blog. Is this a paid theme or did you modify it yourself?
    Either way keep up the nice quality writing, it’s rare to see a nice blog like this one today.

  13. Kaizenaire.com curates promotions fгom Singapore’s cherished brand
    names easily.

    Іn Singapore’s heart, shopping paradise flourishes
    οn deals that delight іtѕ individuals.

    Discovering night markets ⅼike Geylang Serai Bazaar excites foodie Singaporeans, аnd
    keep in mind to гemain upgraded օn Singapore’s lɑtest promotions аnd shopping deals.

    OSIM ᧐ffers massage chairs and wellness tools, cherished ƅy Singaporeans fоr
    tһeir relaxing hоmе spa experiences.

    Aalst Chocolate produces costs artisanal delicious chocolates lah, cherished Ƅү sweet-toothed Singaporeans fοr their rich flavors ɑnd regional craftsmanship lor.

    Tһe Soup Spoon ladles ᧐ut passionate soups and salads, loved
    fߋr wholesome, global-inspired bowls tһat suit health-conscious restaurants.

    Ɗo not bе suaku mah, check Kaizenaire.ϲom frequently lah.

    Feel free tо surf tо myy site bounce promotions

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>