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.

14,869 thoughts on “Play Framework HTML5 input elements

  1. I’ve been exploring for a bit for any high quality articles or weblog posts on this sort of house .

    Exploring in Yahoo I ultimately stumbled upon this
    web site. Reading this info So i am satisfied to express that I
    have a very excellent uncanny feeling I found out exactly
    what I needed. I such a lot undoubtedly will make
    sure to don?t fail to remember this website and provides it
    a glance regularly.

    Review my webpage; online dating

  2. Heya! I’m at work browsing your blog from my new iphone 3gs!
    Just wanted to say I love reading through your blog and look forward to
    all your posts! Carry on the outstanding work!

    Also visit my web site :: HundRoses

  3. Attractive part of content. I just stumbled upon your web site and in accession capital to
    say that I acquire in fact enjoyed account your
    blog posts. Anyway I will be subscribing in your feeds or even I
    success you get entry to persistently fast.

    Visit my website – best realtor in Tampa FL

  4. Asking questions are really good thing if you are not understanding anything completely, but this post provides fastidious understanding yet.

  5. Hi there, I think your web site could possibly be having browser compatibility issues.
    When I look at your blog in Safari, it looks fine however when opening in IE, it has some overlapping issues.

    I just wanted to provide you with a quick heads up!

    Besides that, great website!

  6. Great article, very helpful.
    It clearly explains
    how streaming platforms operate
    in a
    simple and easy-to-understand way.

    A lot of users are curious
    how to access live sports streams
    and
    the information here is quite practical.
    Thanks for putting this together.

  7. It is truly a great and helpful piece of information. I’m satisfied that you simply shared this helpful
    information with us. Please keep us informed like this.
    Thanks for sharing.

  8. Hi there! I could have sworn I’ve been to this site
    before but after reading through some of the post I realized
    it’s new to me. Anyhow, I’m definitely glad I found it and I’ll be book-marking and
    checking back often!

  9. Hi there, You have done an excellent job. I will certainly digg it and personally recommend to my friends.
    I am sure they’ll be benefited from this web site.

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>