I have the latest stable version of paragraphs installed and the 8.x-3.x version of the field group module installed. I'm getting the following ajax error when trying to create a paragraph via the admin.

TypeError: Argument 2 passed to field_group_field_group_form_process_build_alter() must implement interface Drupal\Core\Form\FormStateInterface, null given, called in /srv/bindings/code/web/core/lib/Drupal/Core/Extension/ModuleHandler.php on line 539 in field_group_field_group_form_process_build_alter() (line 429 of /srv/bindings/code/web/modules/contrib/field_group/field_group.module)
#0 /srv/bindings/code/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(539): field_group_field_group_form_process_build_alter(Array, NULL, Array)
#1 /srv/bindings/code/web/modules/contrib/field_group/field_group.module(338): Drupal\Core\Extension\ModuleHandler->alter('field_group_for...', Array, NULL, Array)
#2 /srv/bindings/code/web/modules/contrib/field_group/field_group.module(276): field_group_form_process(Array)
#3 [internal function]: field_group_form_pre_render(Array)
#4 /srv/bindings/code/web/core/lib/Drupal/Core/Render/Renderer.php(378): call_user_func('field_group_for...', Array)

Looks like there has been a lot of movement on this branch in the past 5 days, so I decided to revert back to a commit hash before those changes and it fixes this issue. Has anyone else run into this?

Comments

jsheffers created an issue. See original summary.

justin2pin’s picture

I just got the same error. What commit did you roll back to?

justin2pin’s picture

Status: Active » Needs review
StatusFileSize
new973 bytes

A recent commit made $form_state and $form parameters optional here:

function field_group_form_process(array &$element, FormStateInterface $form_state = NULL, array &$form = []) {

But not in the subsequently called hook_field_group_form_process_build, here:

function field_group_field_group_form_process_build_alter(array &$element, FormStateInterface $form_state, array &$form) {

Attached patch makes the $form_state and $form parameters optional for hook_field_group_form_process_build and solves this issue in my environment.

justin2pin’s picture

Apologies, I should have looked closer at that last patch. This should be the correct one.

rivimey’s picture

@justin2pin I encountered the same problem, and decided to fix it by making the form_state arg nullable:

- function field_group_field_group_form_process_build_alter(array &$element, FormStateInterface $form_state, array &$form) {
+ function field_group_field_group_form_process_build_alter(array &$element, ?FormStateInterface $form_state, array &$form) {

This is a php 7.1 feature, which is works for me on 7.2 but I'm not sure if it's generally ok at present. Php 7.0 has already reached official end-of-life, and is due to be dropped from D8 imminently.

I'm not sure if your patch:

- function field_group_field_group_form_process_build_alter(array &$element, FormStateInterface $form_state, array &$form) {
+ function field_group_field_group_form_process_build_alter(array &$element, FormStateInterface $form_state = NULL, array &$form = []) {

is equivalent to mine in this regard or not.

In some ways I'd prefer that the type was left out of the php signature for the moment.

rivimey’s picture

Issue summary: View changes

Tweak issue description length, make 'pre'.

jsheffers’s picture

The patch listed here won't apply for me with the latest dev commit. @justin2pin

This patch does apply and it works. However the fields in my groups are not grouping properly anymore.

Edit: Looks like I need the paragraphs patch here:
https://www.drupal.org/files/issues/2907094_7_field_group_support.patch

All works fine now.

sime’s picture

@jsheffers isn't that patch in Paragraphs 8.x-1.7 already? Which version of Paragraphs are you using?

jsheffers’s picture

@sime we're using 8.x-1.7, didn't seem to be working before the patch...

sime’s picture

Thanks. I'll try and verify this - there is a pending RC I believe and a regression with paragraphs is not ideal :P

kumkum29’s picture

Ok for me with the patch #4.
Do you think include this correction in the dev version?

thanks.

  • zuuperman committed 17c7dd4 on 8.x-3.x authored by justin2pin
    Issue #3041519 by justin2pin: Fatal error when creating a paragraph
    
nils.destoop’s picture

Status: Needs review » Fixed

Thx for the patch. I committed it to dev

nils.destoop’s picture

I temp removed the typehint, as drupal 8.6 still supports php 5.6

Status: Fixed » Closed (fixed)

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