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

  1. What’s Taking place i’m new to this, I stumbled upon this I
    have found It positively helpful and it has aided me out
    loads. I hope to give a contribution & assist other
    users like its helped me. Good job.

  2. I don’t know if it’s just me or if everyone else experiencing problems with your blog.

    It looks like some of the written text on your posts are running off the screen. Can somebody else please comment and let me know if this is
    happening to them too? This may be a problem with my internet browser
    because I’ve had this happen before. Many thanks

  3. I blog often and I genuinely thank you for
    your information. This great article has really peaked my
    interest. I’m going to take a note of your website and keep checking for new details about once a
    week. I opted in for your RSS feed as well.

    Feel free to surf to my blog post: BOBATOTO

  4. I’m amazed, I have to admit. Seldom do I come across a blog
    that’s both equally educative and engaging, and let
    me tell you, you have hit the nail on the head.
    The problem is something not enough folks are speaking intelligently about.
    I am very happy I stumbled across this during my search for something relating to this.

  5. Hiya very nice site!! Man .. Beautiful .. Wonderful ..
    I will bookmark your website and take the feeds additionally?
    I’m happy to find numerous helpful info here within the submit, we want develop more strategies on this
    regard, thanks for sharing. . . . . .

    Here is my page; idrtoto

  6. I never imagined I’d say this at only 14, but life changes you after my dad disappeared from our
    lives completely.

    We lived in the heart of Berlin and our house used to
    mean stability. But when the bills started to overflow, our security faded away.

    We tried to hold on, but in the end, we had no other choice but to give up our home.

    Watching her fall apart made me feel older than I should be.
    I knew I couldn’t just sit there.

    I began searching for ways people manage in financial crises.
    That’s when I came across stories of people using cryptocurrencies and converting them safely
    into money through trusted platforms.

    I told my mother she could explore that—not because I understood everything, but because I wanted to
    help. She looked into it, researched for days, and eventually chose Paybis (Paybis).
    She said it felt straightforward enough for her to try.

    Her voice trembled when she whispered “I hope
    this works”. When it went through, we
    both let out a breath we didn’t know we were holding.

    From that moment, our life began to stabilize step by step.
    My mom handled everything herself, but she always said my encouragement gave her
    courage.

    I realized that love makes you stronger than you think.

    Today, we’re far from perfect, but we’re no longer drowning.
    And every time my mom looks at me and smiles, she reminds me how
    everything changed the day she found the strength to use Paybis to convert her crypto into something we
    could actually live on.

    Hope is the only thing that kept us moving.

  7. Good day! This is my 1st comment here so I just wanted to give a quick shout
    out and say I genuinely enjoy reading through your articles.

    Can you suggest any other blogs/websites/forums that deal with the same subjects?
    Appreciate it!

  8. It’s going to be finish of mine day, but before end I
    am reading this impressive post to increase my experience.

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>