Fix Render #pre_render callbacks must be methods of a class that implements TrustedCallbackInterface for Drupal 9 compatibly

Created on 13 July 2021, over 3 years ago
Updated 23 October 2023, about 1 year ago

Problem/Motivation

I get the folling error useing the ERL Module with Feld Group 3.1 and Drupal 9:

Drupal\Core\Security\UntrustedCallbackException: Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was field_group_form_pre_render. See https://www.drupal.org/node/2966725 in Drupal\Core\Render\Renderer->doTrustedCallback() (line 96 of /app/site/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php).

Proposed resolution

I created a patch and removed

        if (function_exists('field_group_form_pre_render')) {
          $element['entity_form']['#pre_render'][] = 'field_group_form_pre_render';
        }

And kept

         if (function_exists('field_group_form_process')) {
          $element['entity_form']['#process'][] = 'field_group_form_process';
        }
🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024