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.

14,606 thoughts on “Play Framework HTML5 input elements

  1. This is a well-written post about betting platforms. I found it useful how you explained
    the importance of using trusted platforms.

    From what I’ve seen, platforms like UFABET888 are frequently mentioned because they provide consistent service and fast withdrawals.

    Many bettors have trouble to find trustworthy platforms,
    so content like this is very helpful.

    Thanks for sharing — this will definitely help beginners avoid risky websites.

  2. This is a very informative post about online casinos.
    I appreciate how you explained the importance of choosing reliable sites.

    From what I’ve seen, UFABET888 are frequently mentioned because they offer stable performance
    and quick payouts.

    Many players usually find it difficult to find trustworthy platforms, so content
    like this is extremely useful.

    Thanks for sharing — this will definitely help both beginners and experienced
    players avoid risky websites.

  3. I was suggested this blog by my cousin. I am not sure
    whether this post is written by him as no one else know such detailed about
    my trouble. You are incredible! Thanks!

  4. I know this if off topic but I’m looking into starting my
    own weblog and was curious what all is required to get set up?

    I’m assuming having a blog like yours would cost a pretty penny?
    I’m not very web smart so I’m not 100% sure. Any recommendations or advice would be greatly
    appreciated. Thank you

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>