Problem/Motivation

Hi, thanks for this excellent module.
I have recently noticed that if you have both, Layout Paragraphs and Field Group Module activated, an error is generated that prevents adding new paragraphs. When you click on the add paragraph button (in node/edit), the loader is displayed but never loads the modal window.

Steps to reproduce

Just activate Field group and the issue appears. As soon as Field Group is disabled it disappears.

Errors in console:
js_21Ozn8Y_cs27kOqKPuSyHJWPP-k0rIyS42PUFxGQpws.js:2 POST http://local.mydomain:8888/node/1/edit?destination=/admin/content&ajax_f... 500 (500 Service unavailable (with message))

js_21Ozn8Y_cs27kOqKPuSyHJWPP-k0rIyS42PUFxGQpws.js:1499 Uncaught Drupal.AjaxError {message: "↵Hubo un error HTTP AJAX.↵Código de Resultado HTTP… error inesperado. Vuelva a intentarlo más tarde.", name: "AjaxError"}

Drupal: 9.0.2
Layout Paragraphs: 1.0.0-beta3 (also in 1.0.x-dev)
Field Group: 8.x-3.1
Admin theme: Seven

Thanks in advance!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ktegory created an issue. See original summary.

Dom.’s picture

Status: Active » Needs review
FileSize
1.64 KB

The reason for this can be found in the logs :
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 dans Drupal\Core\Render\Renderer->doTrustedCallback() (ligne 96 de C:\wamp\www\freelance-drupal\web\core\lib\Drupal\Core\Security\DoTrustedCallbackTrait.php).

This module uses "field_group_form_pre_render" function in '#pre_render'. This method is deprecated in field_group and kept for BC reason.

The solution is litterally in the documentation of that method and usage can be found in the paragraph widgets of paragraph module itself: use [FormatterHelper::class, 'formProcess'] if defined.

The patch attached does just that. The code comes from ParagraphWidget.php and InlineParagraphWidget.php code.

ktegory’s picture

Thanks Dom!
I'm going to apply this patch and test how it works in my installation.

ktegory’s picture

Just to confirm that in my case, the patch from @Dom. in #2 works as expected.

  • justin2pin committed cb78444 on 1.0.x authored by Dom.
    Issue #3161489 by Dom., ktegory: Not working if Field Group module is...
justin2pin’s picture

Status: Needs review » Fixed

Thanks y'all! Just pushed #2 to 1.0.x.

  • justin2pin committed 87d2b73 on 1.0.x authored by Dom.
    Issue #3161489 by Dom., ktegory, justin2pin: Not working if Field Group...
justin2pin’s picture

Found an issue with patch #2 actually -- it was targeting the wrong form element key ("subform" instead of "entity_form"). Fixed in latest commit, just documenting here.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.