Problem/Motivation

Working with commerce, I'm getting this error when going to add a product and a store has not been created yet:

( ! ) Fatal error: Call to a member function getMode() on a non-object in /my/project/web/modules/contrib/field_group/field_group.module on line 120

Problem here is that ProductForm class is overriding ContentEntityForm::buildForm() and bypassing the parent implementation under some circumstances.
Thing is that field_group_form_alter() is assuming that $form_state->getStorage()['form_display'] is always present, but this is not always true, as in this case.

Proposed resolution

Add a check to trigger the field_group process only if the form mode is explicitly declared

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

CommentFileSizeAuthor
#2 check_form_mode-2720287-2.patch1.3 KBplopesc
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

plopesc created an issue. See original summary.

plopesc’s picture

Status: Active » Needs review
FileSize
1.3 KB

Attaching patch that checks the existence of the form mode before triggering the process.

Thanks

  • zuuperman committed 8ccbf5c on 8.x-1.x authored by plopesc
    Issue #2720287 by plopesc: Check if form mode is present before trying...
nils.destoop’s picture

Status: Needs review » Fixed

Thx for the patch. I committed it to dev.

Status: Fixed » Closed (fixed)

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