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.

20,112 thoughts on “Play Framework HTML5 input elements

  1. I’m not sure where you are getting your information,
    but good topic. I needs to spend some time learning much more or understanding more.
    Thanks for magnificent info I was looking for this
    information for my mission.

  2. Hello, i think that i saw you visited my web site so i came to “return the favor”.I’m trying to
    find things to enhance my web site!I suppose its ok to use some of your
    ideas!!

  3. In fact no matter if someone doesn’t be aware of after that its up
    to other visitors that they will help, so here it occurs.

  4. I knopw thiss web siute gives qualify baed articles annd extra material, iss thwre anny ofher sitfe whoch ofters tese infokrmation inn quality?

    Stopp by mmy website; desixxx.biz

  5. Wow, wonderful blog layout! How long have you been blogging for?
    you made blogging look easy. The overall look of your web site is great,
    let alone the content!

  6. First of all I would like to say awesome blog!
    I had a quick question which I’d like to ask if you do not
    mind. I was interested to know how you center yourself and clear your thoughts before writing.

    I’ve had a hard time clearing my mind in getting my ideas out
    there. I do take pleasure in writing but it
    just seems like the first 10 to 15 minutes are usually wasted just trying to figure out how to
    begin. Any suggestions or hints? Cheers!

  7. Heya i am for the primary time here. I came across this board and I in finding It truly helpful & it helped me out much.

    I’m hoping to present something again and help
    others like you helped me.

  8. SUPER33 Indonesia Modern Platform merupakan platform digital modern yang menghadirkan pengalaman akses cepat, tampilan premium, dan layanan interaktif dalam satu tempat.
    Dengan desain yang responsif serta teknologi yang stabil, SUPER33 memberikan kenyamanan bagi pengguna
    dalam menikmati berbagai fitur modern secara praktis melalui perangkat mobile maupun desktop.

    Didukung dengan sistem yang aman, navigasi yang ringan, dan tampilan elegan, SUPER33 Indonesia Modern Platform dirancang
    untuk memberikan pengalaman digital yang lebih nyaman, efisien, dan mudah digunakan kapan saja.

    Platform ini juga menghadirkan suasana modern dengan dukungan layanan responsif
    sehingga pengguna dapat menikmati akses yang lebih
    optimal dan profesional.

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>