Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#2 | check_form_mode-2720287-2.patch | 1.3 KB | plopesc |
Comments
Comment #2
plopescAttaching patch that checks the existence of the form mode before triggering the process.
Thanks
Comment #4
nils.destoop CreditAttribution: nils.destoop as a volunteer and at Wunder commentedThx for the patch. I committed it to dev.