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.

21,312 thoughts on “Play Framework HTML5 input elements

  1. Good post. I learn something new and challenging
    on sites I stumbleupon every day. It will always be exciting to read articles
    from other writers and practice a little something
    from other web sites.

  2. Кабанчик (Road to Owner) от cpa.tg — игра-симулятор арбитража в
    Telegram. Заходи, забирай стартовые пятаки и жетон входа.

  3. Wonderful goods from you, man. I’ve understand your stuff prior to and you’re just too magnificent.

    I really like what you have received here, really like what you’re saying and the way in which you say it.

    You make it enjoyable and you continue to care for to
    stay it wise. I can’t wait to read much more from you.
    That is actually a tremendous site.

  4. Aw, this was a very good post. Taking a few minutes and actual effort to generate a very good article…
    but what can I say… I put things off a whole
    lot and never manage to get anything done.

  5. Great site you’ve got here.. It’s hard to find good quality writing like yours these days.
    I really appreciate people like you! Take
    care!!

  6. I think the admin of this site is actually working hard
    in support of his site, as here every stuff is quality
    based information.

  7. I always spent my half an hour to read this weblog’s posts every day along with a mug of coffee.

  8. Справді гарна публікація. Приємно читати такі матеріали.

    Herе is mү web-site: digital

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>