Play 2.7 migration - custom fieldConstructor uses httpContext

Hey,
I’m migrating a play 2.6 project to play 2.7 and got a problem were I haven’t found a solution yet. I have a custom fieldConstructor which basically looks like this:

@import helper.FieldElements

@(elements: FieldElements)

<div class="input-group @elements.args.get('_class) @if(elements.hasErrors) {error}">
    @if(elements.args.get('_label)) {
        <label class="input-label mini" for="@if(elements.args.get('readonly).isEmpty) {@elements.id}">@elements.label </label>
    }
    <div class="input-field">
        @elements.input
    </div>
    <div class="input-notice">
    @if(elements.args.get('_showConstraints).isDefined) {
        <span class="required mini">*@Messages("default.required")</span>
    }
    @if(elements.hasErrors) {
        <span class="error mini">@elements.field.errors.map(error => Messages(error.message, if(error.args.size == 1) { error.args.head } else { error.args })).mkString(" ")</span>
    }
    </div>
</div>

As you can see, I’m using Messages in the fieldConstructor.
In templates the fieldConstructor gets used like following:

@import play.data.Form

@(loginForm: Form[Login])(implicit request: Http.Request, messages: play.i18n.Messages)

@implicitFieldConstructor = @{ FieldConstructor(fieldConstructor.f) }

@main(messages("login.title")) {
  ...
}

The migration guide states that the httpContext should be deactivated and that objects like Http.Request or Messages should be implicit parameters in templates which get used in controllers. I did exactly that and it works everywhere perfectly fine except in the fieldConstructor.

So simply changing:

from
@(elements: FieldElements)
to
@(elements: FieldElements)(implicit request: Http.Request, messages: play.i18n.Messages)

in the fieldConstructor does not work it seems, as it doesn’t compile anymore.

Well I don’t know how to resolve this issue properly and hope you guys can help me with that. If you need any further information let me know :slight_smile: