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

  1. It’s very simple to find out any matter on net as compared
    to textbooks, as I found this article at this web page.

  2. I’m gone to say to my little brother, that he should
    also visit this website on regular basis to obtain updated from hottest news update.

  3. If yoou aare goling for brst cntents lik I do, simply paay a visit this webb site daqily
    as it provids feagure contents, thanks

    Take a loolk aat myy website – javkink.com

  4. My brother suggested I might like this blog. He was entirely right.
    This post truly made my day. You can not imagine just how
    much time I had spent for this info! Thanks!

  5. I was very happy to discover this web site. I want to to thank you for ones time due to this wonderful read!!

    I definitely appreciated every part of it and I have
    you book marked to check out new information on your site.

  6. Thanks for these pointers. One thing I should also believe is credit cards providing a 0 rate of interest often bait consumers together with zero interest rate, instant acceptance and easy on the web balance transfers, however beware of the number one factor that can void your current 0 easy street annual percentage rate and to throw you out into the bad house quickly.

  7. You really make it seem so easy with your presentation but I find this matter to be really
    something which I think I would never understand. It seems too complicated and extremely broad for me.

    I’m looking forward for your next post, I will try to get the hang of
    it!

  8. I’m not sure where you’re getting your info, but good topic.
    I needs to spend some time learning much more or understanding more.
    Thanks for magnificent information I was looking
    for this info for my mission.

  9. Helpful info. Fortunate me I found your web site by chance,
    and I’m shocked why this accident didn’t took place in advance!
    I bookmarked it.

  10. Just want to say your article is as astounding. The clearness in your post is
    just excellent and i could assume you’re an expert on this
    subject. Fine with your permission let me to
    grab your feed to keep up to date with forthcoming post.
    Thanks a million and please carry on the gratifying work.

  11. Great web site you have got here.. It’s hard to find excellent writing like yours nowadays.
    I seriously appreciate people like you! Take care!!

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>