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

  1. I have observed that online degree is getting preferred because accomplishing your college degree online has developed into popular alternative for many people. A huge number of people have not had an opportunity to attend a normal college or university nevertheless seek the elevated earning potential and career advancement that a Bachelors Degree provides. Still others might have a diploma in one discipline but would wish to pursue another thing they now develop an interest in.

  2. Heya! I’m at work surfing around your blog from my new iphone 3gs!
    Just wanted to say I love reading through your blog and look forward to all your posts!
    Keep up the superb work!

  3. I’velearn sopme jhst rigght sfuff here. Definiteky priice bookmaking ffor revisiting.

    I womder how a loot effokrt you plaqce tto create this type of wonderfuhl
    infodmative site.

    Also viwit myy web-site cnhub.xyz

  4. I do not even know the way I finished up right here, however I thought this post was once
    great. I don’t realize who you are but definitely you’re going to a famous blogger
    when you are not already. Cheers!

  5. I’ve learn several just right stuff here. Definitely value bookmarking for revisiting.
    I wonder how a lot attempt you place to create any such magnificent
    informative website.

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>