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.

5,502 thoughts on “Play Framework HTML5 input elements

  1. 놀라운 것들입니다. 당신의 포스트를 보고 매우 만족합니다.
    정말 감사합니다 그리고 당신에게 접촉하고 싶습니다.
    이메일을 보내주시겠습니까?

    Today, I went to the beach front with my kids. 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!

    This is one of the best blogs I’ve come across
    in a while! Your writing style is so engaging, and the content
    is excellent. Do you have any advice for new bloggers on how to create content as compelling as yours?
    Appreciate it!

    와, 이 블로그는 정말 인상적입니다! Blog de Dómina Skade에 대한 포스트가 너무 명확하고 흥미로워요.

    친구들에게 공유할게요. 더 많은 시각적 요소를 추가하면 어떨까요?
    고맙습니다!

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>