Problem/Motivation
When try to make a donation receive
"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 core\lib\Drupal\Core\Security\DoTrustedCallbackTrait.php). "
Steps to reproduce
In use:
"drupal/core-recommended": "^9.2",
"drupal/field_group": "3.2",
"drupal/commerce_donation_flow": "^1.0@beta"
Configure everything like in instruction:https://www.drupal.org/project/commerce_donation_flow
Go to http://site.local/donate/ after redirect to http://site.local/donate/25/donation and got:
"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 core\lib\Drupal\Core\Security\DoTrustedCallbackTrait.php). "
Proposed resolution
Change passing prerender function.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3231024-pre-render-callback-error-3.patch | 1.42 KB | mrweiner |
Issue fork commerce_donation_flow-3231024
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
mrweiner commentedI'm not sure that the correct method is being called in the MR.
As such, attached patch calls fromProcess() instead of entityViewPrender().
Comment #4
mrweiner commentedComment #5
mrweiner commentedActually my last patch errors out due to some pass by reference error. There's a related problem being worked on in https://www.drupal.org/project/field_group/issues/2894213. I don't know if we can actually use the same pre_render implementation as before until a TrustedCallback exists to replicate the behavior. entityViewPrender may be the best bet for now, not sure
Comment #6
mrweiner commentedScratch that -- I think patch #4 is the correct approach. There's a patch in field_group that addresses the problem:https://www.drupal.org/files/issues/2021-06-11/3218305-formprocess-shoul...
Unfortunately that just means that people need to apply that patch for this one to work correctly.
Comment #7
frankdesign commentedThanks for the advice @mrweiner. Patch at #3 above along with patch #2 at https://www.drupal.org/project/field_group/issues/3218305 solved the issue for me.
Comment #9
fathershawnThis needs manual testing because of the upstream issue. Test passes on my local (with Commerce deprecation notices) with the field_group patch in place.
Added Field Group as an explicit requirement. Be sure to use v3.2
Anyone using composer patches can add the following in their composer.json
In the "extra" section of your composer.json
Comment #10
fathershawnManually verified on a fresh D9 install
Comment #12
fathershawnComment #13
fathershawnRe-opening. I missed that we test for field_group being present. It should not be a requirement
Comment #15
fathershawn