Play 2.7 migration - custom fieldConstructor uses httpContext

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.label </label>
    <div class="input-field">
    <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"> => Messages(error.message, if(error.args.size == 1) { error.args.head } else { error.args })).mkString(" ")</span>

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


@(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:

@(elements: FieldElements)
@(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: