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.

15,261 thoughts on “Play Framework HTML5 input elements

  1. Hi there would you mind stating which blog platform you’re using?

    I’m going to start my own blog in the near future but I’m having a hard
    time selecting between BlogEngine/Wordpress/B2evolution and
    Drupal. The reason I ask is because your design and style seems different then most blogs and I’m looking for something unique.
    P.S Sorry for getting off-topic but I had to ask!

    Here is my web page :: 부산토닥이 도박

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

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

  3. Have you ever thought about adding a little bit more than just your articles?
    I mean, what you say is important and everything.
    But think about if you added some great photos or videos to give your posts more, “pop”!
    Your content is excellent but with images and videos, this blog could undeniably be one of the very best in its niche.

    Great blog!

  4. Good day! I know this is somewhat off topic but I was
    wondering which blog platform are you using for this site?
    I’m getting fed up of WordPress because I’ve had issues with hackers and
    I’m looking at options for another platform. I would be
    great if you could point me in the direction of a good platform.

    My web page … Roofing

  5. Hey I know this is off topic but I was wondering
    if you knew of any widgets I could add to my blog that automatically tweet my newest twitter updates.

    I’ve been looking for a plug-in like this folding electric bikes for adults
    quite some time and was hoping maybe you would have some experience with something like this.
    Please let me know if you run into anything. I truly enjoy reading your blog and I look forward to your new updates.

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>