Hi there!

On 8.x-3.0-rc1 I got this notice:

Notice: Undefined property: stdClass::$region in field_group_form_process() (line 318 of modules/contrib/field_group/field_group.module).

After looking into this method, I found that on the following line it is assumed the region property is set:
$group_parents[] = empty($group->parent_name) ? $group->region : $group->parent_name;

I don't know if the above is actually correct or if $group->region should be replaced with $group->parent_name since that one is being checked on being empty() or not.

I've also related https://www.drupal.org/project/field_group/issues/3054195 to this issue since it's probably coming from a same kind of situation.

Comments

frankgraave created an issue. See original summary.

seanb’s picture

It seems this should have been fixed by field_group_update_8301(). Have you tried the latest dev version and run all database updates after updating the module?

brianV’s picture

I've encountered this issue as well after updating from 8.x-1.0-rc6 to 8.x-3.0-rc1. It appears that field_group_update_8301() is not being run, as a drush updb returns 'No database updates required' after the module update.

Further more, executing drush ev "echo drupal_get_installed_schema_version('field_group');" returns -1 (ie., SCHEMA_UNINSTALLED), indicating that the schema is not installed.

If I manually set the schema version to 8000 with drush ev "drupal_set_installed_schema_version('field_group', 8000);", the updates then run properly, and the Notice: Undefined property: stdClass::$region in field_group_form_process() (line 318 of modules/contrib/field_group/field_group.module). disappears.

Is it possible that earlier versions of the 8.x-1.x series did not have their schema version set properly upon install?

raghavendra b m’s picture

Assigned: Unassigned » raghavendra b m
raghavendra b m’s picture

StatusFileSize
new621 bytes
raghavendra b m’s picture

StatusFileSize
new624 bytes
raghavendra b m’s picture

Assigned: raghavendra b m » Unassigned
Status: Active » Needs review

I have added 2 patch #5 and #6. Both will work fine

nortmas’s picture

Nope, the patch doesn't work for me.

nortmas’s picture

The requirement is after you've updated the module to 8.x-3.0-rc1 you have to export configurations. If you import the old ones you run into this error.

ara martirosyan’s picture

@nortmas thanks, I confirm it. So basically we can run
drush ev "drupal_set_installed_schema_version('field_group', 8000);"
to set the schema version to 8000, then run
drush updatedb
to make run field_group_update_8301()
and then export configs with drush cex and commit.

shamalainen’s picture

Thank you Ara Martirosyan #10, it worked like a charm!

tmwagner’s picture

Thank you, Ara (#10)
That fixed my issue as well.

Not sure what the line next to the last was about... it is formatted as if it were a line command... I don't think that is the case 🤔
At any rate - problem solved.

jj’s picture

withdrawn

attheshow’s picture

Attaching updated patch that's working better for us.

sharif.elshobkshy’s picture

Hi.

I'm currently using Field Group version 8.x-3.0-rc1 and encountered the same issue.

sharif.elshobkshy’s picture

StatusFileSize
new723 bytes

Hi.

I'm currently using Field Group version 8.x-3.0-rc1 and encountered the same issue.

Patches above will not work.
Those patches are only fixing the warnings triggered by the Field Group module. However, other warnings are being triggered by other modules due to this issue, and not fixed by the patches above.
(ex: Errors triggered by FieldUiTable.php (Field UI core module)).

I fixed the issue globally by executing a config export.
Steps after upgrading:
drush updb -y
drush config-import -y
drush cex -y

The config export added a "region: content" for most third party settings.
The export fixed the issue for me.

However, for those of you that only want to fix the warnings triggered by the Field Group module, attached is the propper patch.
Following the logic behind field_group_update_8301(), region should use "content" as a default value.

Hope that helps.
Regards.

phthlaap’s picture

I have the same problem with this issue. It has been resolved by run update.php

swentel’s picture

Status: Needs review » Closed (works as designed)

Ok, closing then if the update works. Tracking some other errors in #3059614: Undefined property: stdClass::$region in field_group_form_process()

andrew answer’s picture

Status: Closed (works as designed) » Needs review
StatusFileSize
new741 bytes

I ran project with Field Group 8.x-3.0-rc1, Paragraphs and Paragraphs Collection (Experimental Widget). When I open node edit form which have paragraphs, I see same error (see issue title).

Update Field Group with update hook does not fix anything because of getThirdPartyProviders is empty for all entities.

I prepared simple patch for fixing that situation. Please review.

swentel’s picture

Hmm, but this means you do have field groups right? Because otherwise the function wouldn't get that far. So I'm curious how the setup is to see if we can potentially reproduce the notice.

andrew answer’s picture

I analyzed my site today and found what configuration for core.entity_form_display.node.[content type].default.yml doesn't have region key for field_group. Manually add region: content and execute drush cim. All work fine.

andrew answer’s picture

Status: Needs review » Closed (works as designed)
swentel’s picture

#3075264: Fix upgrade path to account for DS regions should probably fix this once at for all btw, but thanks for the check!

alberto56’s picture

I'm still getting this.

Upgrading from field_group 1.x to 3.0,

# drush pml|grep field_group
  Fields                            Field Group (field_group)                                                   Enabled    8.x-3.0         

Then running drush updb:

[success] Cache rebuild complete.
------------- ----------- --------------- ---------------------------------- 
 Module        Update ID   Type            Description                       
------------- ----------- --------------- ---------------------------------- 
 field_group   8301        hook_update_n   Removed in favor of               
                                           hook_post_update script.          
 field_group   0001        post-update     Assign a region to Field Groups.  
------------- ----------- --------------- ---------------------------------- 


// Do you wish to run the specified pending updates?: yes.                     

>  [notice] Update started: field_group_update_8301
>  [notice] Update completed: field_group_update_8301
>  [notice] Update started: field_group_post_update_0001
>  [notice] Update completed: field_group_post_update_0001

Then visiting an edit node with field groups, I get:

Notice: Undefined property: stdClass::$region in field_group_form_process() (line 366 of modules/contrib/field_group/field_group.module).

I'll reopen this and/or [#3075264 ] and/or a new ticket if I can come up with a reason behind this, or at least steps to reproduce.

alberto56’s picture

As a workaround to #24, I had to manually run the code in field_group_post_update_0001().

swentel’s picture

Hmm weird, I can't think of a reason why it didn't work then when running drush updb ...

nils.destoop’s picture

Idd, very weird. Could it be that you did the update, and immediately after that a config import? If so, you will reset the config again to the original value.
After the update is executed, you need to do a config export to save those changes also to the config files.

ressa’s picture

I am also seeing the "Notice: Undefined property: stdClass::$region ..." error as well as parent groups getting moved down to "Disabled". I'd like to try to manually run the update, could you kindly share a way of doing that @alberto56?

alberto56’s picture

@nils.destoop that's exactly it, it seems. This seems related to #3110362: If an update hook modifies configuration, then old configuration is imported, the changes made by the update hook are forever lost..

@ressa to manually run the update, here's how I did it:

  • backup your database
  • find a way to run php code on your site, for example by running "drush php", "drush ev", or installing the devel_php module
  • run the following php code:
module_load_include('php', 'field_group', 'field_group.post_update');
field_group_post_update_0001();
alberto56’s picture

So to summarize how I fixed this in case anyone else runs into this issue:

On my dev site:

drush updb -y
drush cim -y # I had already run, so I could not reverse it, as mentioned in a previous comment.
drush php
> module_load_include('php', 'field_group', 'field_group.post_update');
> field_group_post_update_0001();
drush cex -y

on my prod site:

drush updb -y
drush cim -y
ressa’s picture

Nice @alberto56, that worked perfectly, thanks for sharing!

After running the php command I got this, so I thought it didn't work, when it in fact worked fine:

PHP Deprecated:  The /Drupal/Core/Path/AliasManager class is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Instead, use /Drupal/path_alias/AliasManager. See https://drupal.org/node/3092086 in /app/web/core/lib/Drupal/Core/Path/AliasManager.php on line 135
=> null

It adds region: content under each group instance in fx core.entity_form_display.node.article.default.yml under:

third_party_settings:
  field_group:
    group_image_group:
      children:
        - field_top_image
        - field_top_image_text
        - field_top_image_photo_info
      parent_name: ''
      weight: 5
      label: 'Image label'
      format_type: fieldset
      format_settings:
        label: 'Image label'
        required_fields: true
        id: ''
        classes: ''
      region: content

... and the sub-fields are nicely grouped again under their parent groups in regular and form displays.

jibran’s picture

Version: 8.x-3.0-rc1 » 8.x-3.x-dev
Status: Closed (works as designed) » Needs work

This is also happening when view mode is using the layout builder.

jibran’s picture

Status: Needs work » Needs review
StatusFileSize
new739 bytes

Rerolled #19 against 3.x HEAD.

elfakhar’s picture

StatusFileSize
new853 bytes

this Fix Bug in core_version_requirement: ^8.8 || ^9

damienmckenna’s picture

Status: Needs review » Needs work

The patch needs a little rework to match the Drupal coding standards - the commented-out code should be just removed, and the "else" statement needs to be on a separate line.

nikitagupta’s picture

Assigned: Unassigned » nikitagupta
nikitagupta’s picture

Status: Needs work » Needs review
StatusFileSize
new769 bytes
nikitagupta’s picture

Assigned: nikitagupta » Unassigned
stephen-cox’s picture

Status: Needs review » Reviewed & tested by the community

Patch #37 resolved the error I was seeing on node add and edit forms when grouping fields using tabs.

sershevchyk’s picture

I had an error:
Notice: Undefined property: stdClass::$region in Drupal\field_group\FormatterHelper::formProcess() (line 76 of /app/docroot/modules/contrib/field_group/src/FormatterHelper.php)
and patch #37 resolved this the error too.

rajeev_drupal’s picture

Assigned: Unassigned » rajeev_drupal

#37 resolved this eror. Thanks.

rajeev_drupal’s picture

Assigned: rajeev_drupal » Unassigned
fgm’s picture

Status: Reviewed & tested by the community » Needs work

During a 9.0.6 upgrade, the $display->save() in field_group_post_update_0001() still cause The "hidden" plugin does not exist exceptions, preventing the hook from succeeding.

More details: when examining these form displays, all found on node types, at admin/structure/types/manage/
/form-display, there are two anomalies:

  • A red warning about
    Notice: Undefined index: name in Drupal\field_ui\Element\FieldUiTable::reduceOrder() (line 228 of core/modules/field_ui/src/Element/FieldUiTable.php).
    Drupal\field_ui\Element\FieldUiTable::reduceOrder(Array, Array)
  • All field groups in the display are marked as disabled. When deactivating drag-n-drop one can see that their children have a correcly set parend (and they are displayed as indented), but the field groups are in region hidden.

Trying to set the region back to content, or even trying to delete the field_group, causes that same exception about the hidden pluging not being defined.

On non-node entity types with field groups, the migration succeeds and none of these problems are present.

Similary, when adding a field_group to a form display of an entity type which had none, if the entity type is node, the same exception appears, but it does not appear on other entity types.

fgm’s picture

Status: Needs work » Reviewed & tested by the community

Found the underlying cause: the NodeStorageSchema on that site was not default, and was still defining type=>hidden on an extra "weight" base field.

The post_update hook could have detected use of this now-inconsistent definition and emitted a more usable error. Probably not have fixed it on its own, this being outside its own job defining field groups. But it is not necessarily a blocker for the patch, so resetting to RTBC.

acbramley’s picture

I had the same issue, manually running the post update hook and exporting config fixed it for me.

gustavowal’s picture

Patch #37 works here, Drupal 8.9.x.

aiphes’s picture

Hello,

Facing this notice too. v 8.x.3.1
Notice : Undefined property: stdClass::$region dans Drupal\field_group\FormatterHelper::formProcess() (/home/xx/www/xx/sited8/modules/contrib/field_group/src/FormatterHelper.php ligne 76)

Will try the patch to see it fix it.

attheshow’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new769 bytes

Adding an updated patch since the previous one was no longer applying cleanly.

kim.pepper’s picture

Issue tags: +#pnx-sprint
marioheber’s picture

Hello!

On 8.x-3.0-rc1 I got this notice:

Notice: Undefined property: stdClass::$region in Drupal\field_group\FormatterHelper::formProcess() (line 76 of modules/contrib/field_group/src/FormatterHelper.php).

Patch #48 works here, Drupal 9.2.x

baikho’s picture

Status: Needs review » Reviewed & tested by the community

#48 works, thank you.

gngn’s picture

#37 works for us.

@attheshow in #48

updated patch since the previous one was no longer applying cleanly.

#37 and #48 look exactly the same to me...

dpacassi’s picture

#48 has been working on a project of mine for months now, +1 ready to be committed

  • swentel committed a0b7ec6 on 8.x-3.x
    Issue #3059614 by Raghavendra B M, attheshow, nikitagupta, Andrew Answer...
swentel’s picture

Status: Reviewed & tested by the community » Fixed

committed and pushed, thanks all.

swentel’s picture

Status: Fixed » Closed (fixed)
jakegibs617’s picture

#48 and #37 are no longer working for me having upgraded to d10. "drupal/field_group": "^3.4"

looks like the code is now in the new version so we don't need the patch anymore. Can someone confirm?