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.

18,509 thoughts on “Play Framework HTML5 input elements

  1. For most up-to-date information you have to go to see world wide
    web and on web I found this web page as a most excellent
    site for most up-to-date updates.

  2. Bizzo Casino features online slots, card games, and live dealer experiences with
    accessible registration, exciting bonuses, secure login, and a user-friendly
    platform for worldwide players.

  3. I know this if off topic but I’m looking into starting my
    own blog and was wondering what all is required to
    get setup? I’m assuming having a blog like yours would
    cost a pretty penny? I’m not very internet savvy so I’m not 100%
    positive. Any recommendations or advice would be greatly appreciated.
    Appreciate it

  4. یکی از دوستام به اسم رضا قبلاً درباره این موضوع سوال
    می‌کرد و من هم از همون موقع کنجکاو شدم.
    سلام، راستش کمتر پیش میاد جایی نظر بنویسم.
    مدتی قبل وقتی یکی از دوستام درباره پیش‌بینی فوتبال حرف می‌زد اینجا برام
    جالب شد. همون ابتدا به نظرم
    نسبتاً مرتب بود. چیزی کهبرای من مهم بود اینه که
    نباید فقط به ظاهر سایت اعتماد کرد.

    یکی از همکارام می‌خواست بدونه
    کدوم سایت‌ها اطلاعات شفاف‌تری دارن.
    همین باعث شد من هم دقیق‌تر نگاه کنم.
    برداشت من این بود که برای کسی که تازه با این فضا
    آشنا می‌شه قابل فهم بود. از طرفی در چنین موضوعاتی احتیاط از همه چیز مهم‌تره.
    برای کسایی که دنبال اطلاعات درباره شرط بندی هستن، بهتره در کنار چند گزینه دیگه بررسی
    بشه. وقتی این حوزه رو نگاه می‌کنی برندهایی
    مثل سایت enfejaronliine و sibbet در بین بعضی کاربران شناخته‌تر شدن.یکی از آشناهای من بیشتر دنبال پیش‌بینی ورزشی
    بود و همیشه می‌گفت اگر سایتی توضیحات ساده
    و روشن نداشته باشه، بهتره آدم با احتیاط بیشتری جلو بره.
    دریک نگاه کلی ارزش وقت گذاشتن داشت.
    از نظر من کسی که وارد این فضا می‌شه باید هم تجربه بقیه رو بخونه و هم خودش بررسی کنه.
    من احتمالاً بعداً دوباره برمی‌گردم و بخش‌های بیشتری رو نگاه می‌کنم، چون بعضی قسمت‌هاش برای مقایسه با
    سایت‌های دیگه قابل توجه بود.

    Fеel free to suirf to my web-site; ۴. دسترسی آسان و حل مشکل فیلترینگ (shartbandipardakht.com)

  5. I was extremely pleased to uncover this page. I want to to thank you for your time due to this wonderful read!!
    I definitely savored every part of it and I have you saved to
    fav to check out new information in your website.

  6. When I initially commented I clicked the “Notify me when new comments are added” checkbox and
    now each time a comment is added I get three emails with the
    same comment. Is there any way you can remove me from that service?

    Cheers!

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>