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.

13,367 thoughts on “Play Framework HTML5 input elements

  1. Hi there, I discovered your blog by way of Google whilst looking
    for a comparable subject, your web site got here up, it looks
    good. I’ve bookmarked it in my google bookmarks.

    Hi there, simply was alert to your blog through Google, and found that it
    is really informative. I am gonna watch out for brussels.
    I will appreciate should you proceed this in future. A
    lot of other people will probably be benefited out of your
    writing. Cheers!

  2. Wow, superb blog layout! How long have you been blogging for?
    you made blogging look easy. The overall look of your
    web site is excellent, as well as the content!

  3. You are so cool! I do not believe I have read something like that
    before. So great to discover someone with a few genuine
    thoughts on this issue. Seriously.. thank you for starting this up.

    This site is something that is required on the internet, someone
    with some originality!

  4. This web site truly has all of the information I wanted concerning
    this subject and didn’t know who to ask.

  5. Wonderful article! That is the kind of information that are meant to be
    shared around the net. Disgrace on Google for not positioning this put up higher!

    Come on over and talk over with my site . Thank you =)

  6. cibai
    You’re so cool! I don’t believe I’ve read a single thing like this before.

    So good to discover another person with some original thoughts on this subject matter.
    Really.. thank you for starting this up. This site is something that is needed on the web, someone with a little originality!

  7. I have read so many articles concerning the blogger lovers but this post is
    truly a nice article, keep it up.

  8. Почему пользователи выбирают площадку KRAKEN?

    Маркетплейс KRAKEN заслужил доверие многочисленной аудитории благодаря
    сочетанию ключевых факторов.
    Во-первых, это широкий и разнообразный ассортимент, представленный сотнями продавцов.

    Во-вторых, интуитивно понятный интерфейс KRAKEN, который упрощает навигацию, поиск товаров
    и управление заказами даже для новых
    пользователей. В-третьих,
    продуманная система безопасных транзакций, включающая
    механизмы разрешения споров (диспутов) и возможность использования условного
    депонирования, что минимизирует риски для
    обеих сторон сделки. На KRAKEN функциональность сочетается с внимательным отношением к безопасности клиентов, что делает процесс покупок более предсказуемым,
    защищенным и, как следствие, популярным
    среди пользователей, ценящих анонимность и надежность.

  9. Heya i’m for the first time here. I came across this board
    and I in finding It truly helpful & it helped me out much.
    I hope to offer something back and help others such as you aided me.

  10. Today, I went to the beachfront with my children. I found a sea shell
    and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.”
    She put the shell to her ear and screamed. There was a hermit crab inside and it pinched
    her ear. She never wants to go back! LoL I know this is entirely off topic
    but I had to tell someone!

  11. You could definitely see your skills in the article you write.
    The arena hopes for more passionate writers like you who aren’t afraid to mention how they believe.
    At all times follow your heart.

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>