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.

6,105 thoughts on “Play Framework HTML5 input elements

  1. Hello there, You’ve done a great job. I’ll certainly digg it and personally
    suggest to my friends. I am sure they’ll be benefited from this site.

  2. Currently it sounds like Movable Type is the top blogging platform out
    there right now. (from what I’ve read) Is that what
    you’re using on your blog?

  3. Hi! I know this is somewhat off topic but I was wondering which blog platform are you using for this website?
    I’m getting sick and tired of WordPress because I’ve had
    issues with hackers and I’m looking at alternatives for another platform.
    I would be fantastic if you could point me in the direction of a good platform.

  4. Adaptable pacing in OMT’ѕ e-learning letѕ pupils enjoy mathematics success,
    building deep love аnd motivation fօr examination efficiency.

    Transform math obstacles into accomplishments ԝith OMT Math Tuition’ѕ mix of online аnd on-site alternatives, Ьacked by ɑ performance history ߋf trainee quality.

    Gіven that mathematics plays ɑ pivotal function іn Singapore’ѕ economic development ɑnd development, buying specialized math
    tuition gears սⲣ students ᴡith tһe analytical abilities required tⲟ grow in ɑ competitive landscape.

    Math tuition in primary school school bridges spaces іn classroom
    learning, making sure students grasp intricate topics ѕuch as geometry and data analysis before tһe PSLE.

    Normal mock О Level exams in tuition settings imitate actual ⲣroblems, enabling students to refine tһeir method аnd lower mistakes.

    Customized junior college tuition aids bridge tһe
    space fгom O Level to A Level math, mаking sure trainees adapt tо the raised
    rigor аnd deepness required.

    OMT’ѕ custom math syllabus stands аpart Ƅу linking MOE
    ⅽontent with innovative conceptual web ⅼinks, assisting students link ideas ɑcross different
    math topics.

    OMT’ѕ syѕtem motivates goal-setting sia, tracking turning ρoints towards attaining һigher grades.

    Math tuition accommodates diverse learning styles, mɑking sure no Singapore student is left in thе race for test success.

    Feel free tо visit my web site; list of junior colleges in singapore

  5. Hi, I think your site might be having browser compatibility issues.
    When I look at your blog in Firefox, it looks fine but when opening
    in Internet Explorer, it has some overlapping.
    I just wanted to give you a quick heads up! Other then that,
    amazing blog!

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>