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

  1. I have been browsing on-line more than 3 hours lately,
    but I never found any attention-grabbing article like yours.
    It is lovely price enough for me. Personally, if all website owners
    and bloggers made just right content material as you did, the net will be much more useful than ever before.

  2. A conta nova que não para de postar só joga Phoenix Rises no domingo. Diz que paga melhor. A gente riu, os dados concordam.

  3. Hi, this weekend is fastidious in support of
    me, for the reason that this moment i am reading this fantastic educational post here at my residence.

  4. W Casino.org uważnie testujemy i przeglądamy wszystkie najpopularniejsze kasyna, polecając tylko najbardziej godne zaufania strony
    z najlepszymi korzyściami dla gracza i ogólnymi doświadczeniami.

  5. Hi there, You have done an excellent job. I?ll certainly digg it and in my view recommend to my friends. I’m sure they will be benefited from this web site.

  6. Its like you read my mind! You seem to know a lot about this, like you
    wrote the book in it or something. I think that you could do with some pics to drive
    the message home a bit, but other than that, this is magnificent
    blog. A fantastic read. I will certainly be back.

  7. magnificent issues altogether, you simply won a emblem
    new reader. What could you suggest about your post that you made some days ago?
    Any certain?

  8. Write more, thats all I have to say. Literally, it seems as though you relied on the video
    to make your point. You obviously know what youre talking about, why throw
    away your intelligence on just posting videos to your site when you
    could be giving us something informative to read?

  9. After I originally left a comment I appear to have
    clicked the -Notify me when new comments are added- checkbox and from now
    on every time a comment is added I recieve four emails
    with the exact same comment. Is there an easy method you can remove
    me from that service? Many thanks!

  10. Врач нарколог проводит первичный осмотр пациента уточняет сколько дней длится запой какие напитки употреблялись есть ли боль рвотные позывы бессонница панические атаки судороги галлюцинации повышенная тревожность или признаки белой горячки. После этого врач определяет можно ли проводить вывод запоя на дому или лучше организовать лечение в стационаре. Подробнее – вывод из запоя цена в казани

  11. Hi to every body, it’s my first pay a quick visit
    of this web site; this website carries remarkable and genuinely good information designed for readers.

  12. Awesome issues here. I’m very happy to see
    your post. Thank you a lot and I am having a look ahead to contact you.
    Will you kindly drop me a e-mail?

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>