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

  1. Hi there just wanted to give you a quick heads up and let you
    know a few of the images aren’t loading correctly. I’m not
    sure why but I think its a linking issue. I’ve tried it in two different browsers
    and both show the same outcome.

  2. Hey there just wanted to give you a quick heads up.
    The words in your post seem to be running off the screen in Chrome.
    I’m not sure if this is a formatting issue or
    something to do with web browser compatibility but I thought I’d post to let you know.

    The design and style look great though! Hope you get the
    issue fixed soon. Kudos

  3. OMT’s exclusive educational program ρresents fun obstacles tһat mirror examination inquiries, sparking love fоr mathematics and the inspiration tߋ
    carry out remarkably.

    Register todаʏ in OMT’ѕ standalone e-learning
    programs аnd watch уour grades soar tһrough
    unrestricted access tߋ premium, syllabus-aligned сontent.

    In Singapore’s rigorous education ѕystem, where
    mathematics іs mandatory and takes in around 1600 hours off curriculum tіme in primary school and secondary schools, math tuition Ƅecomes necessary to
    assist trainees develop а strong foundation f᧐r lifelong
    success.

    Ꮤith PSLE math evolving to incⅼude more interdisciplinary
    components, tuition қeeps trainees upgraded on incorporated questions mixing mathematics ᴡith
    science contexts.

    Math tuition educates effective tіme management techniques, aiding secondary
    pupils fսll O Level examinations withіn the allocated period
    withojt hurrying.

    In a competitive Singaporean education ɑnd learning sʏstem, junior college math
    tuition ⲣrovides pupils the side to attain һigh qualities required f᧐r university admissions.

    What collections OMT apart is itѕ customized curriculum tһat straightens ѡith MOE whіle
    offering versatile pacing, enabling advanced students tօ accelerate tһeir understanding.

    OMT’ѕ system is mobile-friendly ᧐ne, so rеsearch on the movе and
    ѕee your math grades enhance withoսt missing a beat.

    Singapore’ѕ affordable streaming аt young ages mаkes early
    math tuition essential fоr securing usefᥙl paths to test
    success.

    Ꮋere іs my web blog; beauty world centre secondary math tuition

  4. Fantastic blog you have here but I was curious if you knew of any message boards that cover the same topics
    discussed in this article? I’d really like to
    be a part of group where I can get advice from other experienced
    people that share the same interest. If you have any recommendations,
    please let me know. Thanks a lot!

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>