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

  1. Hi there, I found your website via Google even as searching for
    a related matter, your web site got here up, it seems great.
    I’ve bookmarked it in my google bookmarks.
    Hi there, just changed into alert to your blog thru Google,
    and found that it is really informative. I’m going to be careful for brussels.
    I’ll appreciate if you happen to continue this in future.
    Lots of people will likely be benefited from your writing.
    Cheers!

  2. An outstanding share! I’ve just forwarded this onto a friend
    who was conducting a little research on this. And he in fact ordered me lunch due
    to the fact that I discovered it for him… lol. So let me reword this….

    Thank YOU for the meal!! But yeah, thanx for spending the time to talk about
    this topic here on your website.

    Also visit my web-site – keyboard 88 keys

  3. cibai
    Hello! This is my first visit to your blog!
    We are a collection of volunteers and starting a new initiative in a
    community in the same niche. Your blog provided us valuable information to work on.
    You have done a marvellous job!

  4. This is a very informative post about online casinos
    and betting platforms. I especially liked how it explains the importance of choosing a trusted site
    before registering.

    Many players often ask where to find reliable gaming platforms with fair odds and smooth withdrawals.
    In my experience, checking platforms like milyon88games.com helps users understand what features to look for in a legit online
    casino.

    Thanks for sharing these insights — they’re useful for both beginners and experienced players.

  5. Hi there this is somewhat of off topic but I was wondering if blogs use WYSIWYG editors or if you have
    to manually code with HTML. I’m starting a blog soon but have no coding experience so
    I wanted to get guidance from someone with experience.
    Any help would be greatly appreciated!

  6. YIF, or Youth in Film, represents an interesting intersection of
    youth tradition and the cinematic arts, highlighting the numerous role that young folks play in shaping the movie business and its narratives.
    The illustration of youth in movie has advanced dramatically since the
    early days of cinema. Traditionally, younger individuals from various backgrounds
    have been underrepresented in film, resulting in a slender portrayal of
    youth culture. Films like “Moonlight” (2016) and “The Hate U Give” (2018) have
    brought attention to the experiences of marginalized youth,
    addressing points similar to race, class, and identity.
    One of the most significant features of YIF is its give attention to representation. Nevertheless, recent years have seen a push for better inclusivity and
    diversity in storytelling. Platforms like YouTube,
    TikTok, and Instagram have turn out to be breeding grounds for youth-pushed
    content material, giving rise to a brand new era of storytellers who challenge conventional narratives and push the boundaries of inventive expression. This
    article explores the idea of YIF, its historic context, its
    impact on fashionable cinema, and the ways during which it
    displays broader societal traits. In the 1920s and nineteen thirties, young characters
    typically served as sidekicks or comedian relief, with little depth or complexity.

    These films not only entertained but also provided a platform for young voices, permitting them to see their experiences mirrored in mainstream
    media. The put up-conflict period saw the rise of the
    teenage demographic, leading to films that catered specifically to youthful audiences, reminiscent of “Rebel Without a Trigger”
    (1955) and “The Graduate” (1967). These films not only depicted the struggles of
    youth but also resonated with a era grappling with issues of
    identity, rebellion, and societal expectations.
    Young filmmakers and content material creators gained unprecedented entry to audiences, allowing them to share their tales and perspectives.
    The emergence of the internet and social media
    within the 2000s additional reworked the panorama of YIF.
    The 1980s and nineties marked a big turning level for YIF, as filmmakers started
    to create narratives that centered on the experiences of younger people.
    Films like “The Breakfast Membership” (1985) and “Clueless”
    (1995) explored the complexities of adolescent life, addressing
    themes of friendship, love, and self-discovery.

    Nonetheless, as societal views on adolescence began to
    shift, so too did the portrayal of young individuals
    on screen.

  7. I am sure this piece of writing has touched all the
    internet viewers, its really really pleasant piece of
    writing on building up new weblog.

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>