Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7805365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:12:11+00:00 2026-06-02T02:12:11+00:00

I still struggle with the form validation and form helpers in Play 2.0. I

  • 0

I still struggle with the form validation and form helpers in Play 2.0. I have this login screen that I use together with the Twitter Bootstrap. So my login form looks like this:

    @helper.form(routes.Application.authenticate, 'class -> "form-horizontal") {
    <fieldset>
    <legend>@Messages("login")</legend>

            @if(loginForm.hasGlobalErrors) { 
                <div class="alert alert-error">
                <a class="close" data-dismiss="alert">×</a>
                    @loginForm.globalError.message
                </div>
            }
            @if(flash.contains("success")) {
                <div class="alert alert-success">
                <a class="close" data-dismiss="alert">×</a>
                    @flash.get("success")
                </div>
            }

            @inputText(loginForm("email"), '_label -> "Email")
            @inputText(loginForm("password"), '_label -> Messages("login.password"))


            <div class="form-actions">
                <button type="submit" class="btn btn-success">@Messages("button.doLogin")</button>
                @Messages("or")
                <a class="btn btn-warning" href="routes.LandingPage.index">@Messages("button.doCancel")</a>
            </div>              
    </fieldset>
    }

And my twitter bootstrap field looks like following:

@(elements: helper.FieldElements)

@**************************************************
* Generate input according twitter bootsrap rules *
**************************************************@
<div class="control-group @if(elements.hasErrors) {error}">
    <label class="control-label" for="@elements.id">@elements.label</label>
    <div class="controls">
        @elements.input
        <span class="help-inline">@elements.infos.mkString(", ")</span> 
    </div>
</div>    

This is the output:

Login screen

What I do not understand:

1, Why is the help text visible all te time (on the right side of the input field)

The help text comes from @elements.infos.mkString(", "). So deleting this line will delete the help text. Or you can pass an empty string to supress the helptext being visible: '_help -> ""

2, How to show only the help text if an error occurs?

Help text can be added when using this code: @elements.errors(elements.lang).mkString(", ")

3, What are the possible parameters to pass to an input text field? I want to pass the class name as well, but I do not know how…

I can define my custom arguments to pass (i.e. class or placeholders): class="@elements.args.get('_class) and then I can pass it like this: '_class -> "classname"

4, Can I define more than one implicitFieldConstructors in one template part? Because for the checkboxes I want another fieldConstructor compared to the imput boxes and textarea, but how to do this?

Example for this: In the computer-database sample a Twitter bootstrap field is defined, but then it is used as follows:

@inputText(loginForm("email"), '_label -> "Email")

Why is the name here inputText and not just input? Because there is also an input.scala.html?

So, If I want to make a fieldhandler for the checkbox, how to use this? The following format is giving me errors:

@checkBoxHandler = @{ FieldConstructor(s2ftheme.constructors.checkbox.render) }
@checkbox(loginForm("remember"), '_label -> Messages("login.remeberme"))(handler = implicitFieldConstructor)

I get the error message:

not enough arguments for method apply: (implicit handler: views.html.helper.FieldConstructor, implicit lang: play.api.i18n.Lang)play.api.templates.Html in object checkbox. Unspecified value parameter lang.

I think I am missing the concept here…
Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:12:13+00:00Added an answer on June 2, 2026 at 2:12 am

    The info text comes from @elements.infos.mkString(", "). To show the errors, you should use @elements.errors(elements.lang).mkString(", ") instead.

    The correct parameter to change the infos content would be help (this is a bit inconsistent, you have to read the source to realize this) so if you want to use the built-in bootstrap fields but suppress the infos, you’d pass '_help -> "".

    Edit for #4:

    Here’s how you should call your specific checkbox:

    @checkbox(loginForm("remember"), '_label -> Messages("login.remeberme"))(handler = implicitFieldConstructor, implicitly[Lang])

    And yes, @input means there’s a template called input.scala.html. It’s the basic template for all input helpers.

    To understand why and how this works, you should dive a little deeper into Play 2.0 and Scala (esp. implicit arguments).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im new to linq so i still struggle .... I have a collection of
Still fighting with templates. In this example, despite the fact that is copied straight
I know that this is quite subjective, but is it something that I have
--EDIT-- I believe this is a valid question that may have multiple answers (as
I know that there have been plenty of topics describing this topic but I
I'm sure this will be a simple question but I still struggle with DOM
still new to XML parsing with the iphone so i have a few questions.
Still learning Objective-C / iPhone SDK here. I think I know why this wasn't
Still having issues with this problem. Please help if you can. So I am
Still an iphone dev starter but trying. I would like to have the user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.