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.

19,509 thoughts on “Play Framework HTML5 input elements

  1. Hi I am so delighted I found your site,
    I really found you by error, while I was looking on Google for something else, Regardless I am here now and would just like to say cheers
    for a tremendous post and a all round exciting blog
    (I also love the theme/design), I don’t have time to read through
    it all at the minute but I have book-marked it and also added in your
    RSS feeds, so when I have time I will be back
    to read a great deal more, Please do keep up the awesome work.

  2. If you desire to improve your experience only keep
    visiting this web site and be updated with the most recent gossip posted here.

  3. Undeniably believe that which you said. Your favorite reason appeared to be at
    the web the simplest thing to remember of. I say to you,
    I definitely get annoyed at the same time as other folks consider issues that they plainly do not
    recognise about. You controlled to hit the nail upon the top and also defined out the whole thing with
    no need side-effects , folks can take a signal. Will probably be back
    to get more. Thank you

  4. Do you haqve a spam iszsue oon this website; I also aam a blogger, annd I
    was wantiing too know your situation; we hage developed some nice
    practices aand wwe are looking tto swap strategijes wth other folks,
    please shlot mme aan e-mail iif interested.

    Feeel frese too visijt myy bllog – xnxx18.pro

  5. magnificent post, very informative. I’m wondering why
    the opposite specialists of this sector don’t
    notice this. You must proceed your writing. I’m confident,
    you’ve a great readers’ base already!

  6. My programmer is tryinjg too convince me too movve
    too .net from PHP. I have alwzys disliuked thee idda because off the expenses.
    Butt he’s tryiong none thee less. I’ve bden using Movable-type oon sevsral werbsites foor abbout a yer annd am
    axious bout switching too another platform. I hve hward fantastic things about blogengine.net.

    Is there a way I can transfer alll mmy wordpress ccontent into it?
    Any kind off heelp would bee greeatly appreciated!

  7. Hello there I am so thrilled I found your weblog, I really found you by accident, while I was researching on Google for something else,
    Regardless I am here now and would just like to say cheers for a incredible post and a all round exciting
    blog (I also love the theme/design), I don’t have time to browse it
    all at the minute but I have bookmarked it and also added in your RSS feeds, so when I have time I will be
    back to read a lot more, Please do keep up the great work.

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>