Problem/Motivation

At some point between core ~8.2 and now (8.5), and between 1.x and 3.x of this module, the region part of field group display configurations needs to be set (and isn't set on old configs without re-saving).

This leads to the following PHP notice:

Notice: Undefined index: name in Drupal\field_ui\Element\FieldUiTable::reduceOrder() (line 236 of core/modules/field_ui/src/Element/FieldUiTable.php)

and also results in really weird behavior where field groups themselves appear in the 'hidden' portion of the form, and any fields nested under them appear at the very top of the form.

Proposed resolution

Add a simple update hook to populate the region portion of the display configs. Core had a post update hook (system_post_update_add_region_to_entity_displays() for field display configurations).

Remaining tasks

User interface changes

API changes

Data model changes

Comments

jhedstrom created an issue. See original summary.

jhedstrom’s picture

Status: Active » Needs review
StatusFileSize
new1.08 KB

Hard-coding content here should be ok, since prior to 3.x of this module (and core version 8.3+), field groups could not be configured as 'hidden'. If there are sites with hidden field groups, the region portion of the config will already be set, so this update hook will not overwrite those settings.

jhedstrom’s picture

StatusFileSize
new638 bytes
new1.1 KB

Oops, there was a logic error in #2 after a bit of refactoring. This patch properly updates the region setting for all field groups in a display.

esteinborn’s picture

Confirming the patch in #3 applies cleanly and removes the error stated in the OP.

Thanks.

esteinborn’s picture

Status: Needs review » Needs work

Actually, I am getting a different line for the same error after upgrading to 8.5.3:

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(NULL, Array)
esteinborn’s picture

It looks like my changes were clobbered by two updates at once, disregard. The patch still works

esteinborn’s picture

Status: Needs work » Needs review
kevin.dutra’s picture

Status: Needs review » Reviewed & tested by the community

Yep, the code looks clean and looks like it does what it's supposed to, so moving to RTBC.

kay.beissert’s picture

Same here, patch #3 applies cleanly and removes the errors. Thanks

anybody’s picture

Thank you very much. Confirming RTBC! Is there a plan for a new release?

norman.lol’s picture

Luckily this patch is easily applicable to the current 3-beta release.

  • zuuperman committed 327821e on 8.x-3.x authored by jhedstrom
    Issue #2968184 by jhedstrom: The region part of entity view config isn't...
nils.destoop’s picture

Status: Reviewed & tested by the community » Fixed

Works like a charm. Thx.

Status: Fixed » Closed (fixed)

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

grantkruger’s picture

Confirming that patch at #3 works for me with 8.x-3.0-beta1 on Drupal core 8.6.2. Thanks jhedstrom!

kala4ek’s picture

StatusFileSize
new498 bytes

Even after applying #3 patch I meet the initial errors.
Only after the #16 patch they gone and field groups starts to display.

joelpittet’s picture

@kala4ek It would be worth opening a new issue as this one has been closed as fixed.

norman.lol’s picture

Though the fix is still not released yet. @kala4ek did you try the dev version and after applying the database updates does the problem still persist?

kala4ek’s picture

did you try the dev version and after applying the database updates does the problem still persist?

Yep.

I think we can skip it now, cause with clean install there would not be such a problem,
also, seems #3 helps for other people.
I guess, in my case, it's something project-specific.

jds1’s picture

The patches did not work for me on 8.6.x. The only way I could get this to work was with a clean install of the latest dev release. Think we can get a beta2 release sometime? It has been over a year. Thanks!

EDIT: This is still not fully working for me. Even though both tabs are rendering properly the second tab is still showing as disabled.

EDIT 2: If I export config, manually switch the region, and reimport it finally works.

brightbold’s picture

Thanks for this! Also, if you're having the problem, don't forget the database updates. Without that you will still get the error.

justkristin’s picture

I am with if-jds: nothing is working for me. I am going to attempt a forced replacement of the module files, but I cannot uninstall/reinstall because the site is live and I cannot get time from mgmt to re-do all field groups... The thing works fine on manage form display, but not on manage display, if that means anything. :(

jds1’s picture

Hey justkristin: did you try the thing where you manually switch the region in your config yml files? If it works locally you can probably roll to your live site. It's not the most ideal solution, but you could maybe let mgmt know it's worth the 30min-1hr you would spend on it (if it improves the client experience). Good luck!

vaccinemedia’s picture

Updated to latest dev of Field Group and still getting this:
Notice: Undefined index: name in Drupal\field_ui\Element\FieldUiTable::reduceOrder() (line 228 of /var/www/vhosts/example.com/httpdocs/core/modules/field_ui/src/Element/FieldUiTable.php) #0

If I then move the field groups out of the disabled region and not add any fields to them but simply save them they then stay in the main config region. At this point I can then move them into place and save and they stay where I left them (usually but not always).

chadmandoo’s picture

This is still an issue in rc1 version. The module is currently unusable in its current state and reverting back to 1.0 is not advised due to it no longer being supported. Is there a fix for this?

mpp’s picture

mhmhartman’s picture

I just had a hard time getting rid of these errors.

The following worked for me:

- use 3.x-dev
- add both patches to composer.json:

"drupal/field_group": {
        "Update missing region settings": "https://www.drupal.org/files/issues/2018-04-30/2968184-03.patch",
        "The region part of entity view config isn't set for old installs": "https://www.drupal.org/files/issues/2018-11-29/2968184-16.patch"
      }

- make sure field_group update number is below 8301:
drush ev "drupal_set_installed_schema_version('field_group', 8300)"
- remove composer.lock & run composer install
- run drush updb -y
- run drush cex -y

After this, the notices should be gone & the exported form config should contain the missing regions.

pguillard’s picture

I did what is suggested by @mhmhartman #28 and my "Detail" field groups are still desactivated after migration.
At the same time I have no troubles having field_group 8.x-1.0 with drupal core 8.7.9.
I could also contribute, but I have no hint !

ergophobe’s picture

I followed the steps outlined by mhmhartman in #28, except for applying patch 3 since I'm running 8.x-3.0 and patch 3 was committed before that release.

No change. Still get the same errors on existing field groups in the Form Display.

If I delete them and create new ones, though, it seems to work - no error message. But when I try to enable the field_group (i.e. drag a Tab to nest under a Tabs group), the error comes back and the tab remains disabled.

I could only get this to work by exporting the config for the entity form display, editing manually, and then importing the edits

thetaPC’s picture

#28 worked for me for D8.8 and v3.0.0

After updating to D8.9 and v3.1.0, the patches are no longer needed and everything works great!