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.

12,731 thoughts on “Play Framework HTML5 input elements

  1. I quite like looking through an article that will make people think.
    Also, many thanks for allowing me to comment!

  2. Howdy! I know this is somewhat off topic but I was wondering if you knew
    where I could find a captcha plugin for my comment form?

    I’m using the same blog platform as yours and I’m having
    difficulty finding one? Thanks a lot!

  3. Trending Questions Is HTP addictive? What happens if you combine Strattera and
    Adderall? Is white round pill gpi a325? How many 25mg Xanax equals 2mg Xanax?
    Can you enlist in the french foreign legion with a marijuana charge?

  4. Cool blog! Is your theme custom made or did you download it from somewhere?
    A theme like yours with a few simple adjustements would really make my blog shine.

    Please let me know where you got your design. Bless you

  5. Good post. I learn something totally new and challenging on sites I stumbleupon every day.
    It’s always exciting to read content from other writers and
    practice a little something from their web sites.

  6. I pay a visit day-to-day a few web sites and sites to read articles or reviews, but this weblog gives quality based posts.

  7. Great article! That is the kind of information that are meant to be shared around the net.
    Shame on the seek engines for not positioning this post upper!
    Come on over and talk over with my web site .

    Thank you =)

  8. I’ve been surfing online more than 2 hours today, yet
    I never found any interesting article like yours. It’s pretty worth enough
    for me. In my opinion, if all website owners and bloggers made good content as you did,
    the web will be a lot more useful than ever
    before.

  9. It’s enormous that you are getting thoughts from this article as well as from our dialogue made at this time.

  10. wonderful issues altogether, you just gained a brand new reader.

    What would you suggest in regards to your post that
    you simply made some days ago? Any positive?

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>