Problem/Motivation

Upgrading from 8.1.0 to 8.3.0 makes field group an unusable module. There are several issues in this current version and can only find the following error when attempting to use it:

Notice: Undefined index: name in Drupal\field_ui\Element\FieldUiTable::reduceOrder() (line 228 of /var/www/html/docroot/core/modules/field_ui/src/Element/FieldUiTable.php)

The issues are as follows:

1.) When trying to create a new tab and moving it under tabs directly it just disables it. To get around this you can move the tab out of disable, save it, and then move it under the tabs.

2.) Some fields absolutely refuse to be under a tab while others work perfectly fine. There is no rhyme or reason to this but it just appears that something about the field that field_group does not like and just refuses. I have tried moving from one tab to another, disabling that field, using different type of tab, renaming the tab, uninstalling the module completely, downgrading to the dev version, changing widgets and essentially everything you can do from the front end.

In its current state this module simply doesn't work as intended and the 8.1.0 is no longer supported. This may work for some if the fields somehow do not end up on the "naughty" list of fields that do not seem to work but in my case out of around 20 fields I had 5 that fell into this category.

Proposed resolution

Fix the notice.

Remaining tasks

Comments

chadmandoo created an issue. See original summary.

rgristroph’s picture

I am working on a project that also has this issue.

wturrell’s picture

Workaround (1) is very useful, thanks. I'm yet to experience (2), fields that won't stay under a tab, but it's early days.

mpp’s picture

Status: Active » Needs review
StatusFileSize
new498 bytes

Added patch from https://www.drupal.org/project/field_group/issues/2968184#16

Update: this doesn't fix the issue for us

Status: Needs review » Needs work

The last submitted patch, 4: 3064890_4.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

webczarina’s picture

I have gotten a similar error since upgrading from 8.1.0 to 8.3.0:

Notice: Undefined index: group in Drupal\Core\Render\Element\VerticalTabs::preRenderVerticalTabs() (line 82 of /usr/local/docroot/site/mysite-dev.edu/web/core/lib/Drupal/Core/Render/Element/VerticalTabs.php)

This occurs when users attempt to edit a node where I've set up a field group using vertical tabs.

timcosgrove’s picture

Just chiming in that we also saw this when trying to update from 1.0 to 3.0-rc1. The Paragraphs patch listed as required does not affect the error and appears unrelated.

mpp’s picture

@timcosgrove, the paragraphs issue is related in a sense that it reproduces the error mentioned in this issue. The patch in that issue is indeed unrelated ;-)

mpp’s picture

mpp’s picture

Issue summary: View changes
mpp’s picture

Issue summary: View changes
tbenice’s picture

Im totally unable to move a new field group out of disabled. Doesn't matter what I do. This is on a node form display.

swentel’s picture

Status: Needs work » Closed (duplicate)

There are a bunch of issues indeed with drag / drop and notices. I can also reproduce the tabs thing, it's super annoying .. :)
Going to fix them in #3075264: Fix upgrade path to account for DS regions
Also opened #3085858: Drag and drop acts weird, sometimes not resetting the parent, or even clearing the region value

scott_euser’s picture

I have been trying to follow the various related issues, but none seem to solve.

Ie, I still get Undefined index: name in Drupal\field_ui\Element\FieldUiTable::reduceOrder(). Steps to reproduce:

  1. Enable paragraphs module
  2. Create custom form mode for paragraph
  3. Manage form for a paragraph type and enable the custom form mode
  4. Manage form on the custom form mode, name is missing

Example array passed to reduceOrder

array(
  'children' => array(
    'group_conditions' => array(
      'children' => array(
        'field_condition' => array(
          'name' => 'field_condition',
          'weight' => '0',
        ),
      ),
    ),
    'group_content' => array(
      'children' => array(
        'field_layout' => array(
          'name' => 'field_layout',
          'weight' => '0',
        ),
      ),
    ),
  ),
)

So only key available is children while a key name is expected.

Should I post a new issue?

scott_euser’s picture

Well for now will just leave this patch here, happy to move to a new issue, but definitely still reproducible as per above. This patch just provides extra '#name' attributes for the tabs and tab FieldGroupFormatters so that core field_ui module is able to handle sorting. Not a long term fix; just avoids the notice.

mottihoresh’s picture

Seems like it's a problem with all of the filed group formatters, Attached is a patch for the HTML Element.

mottihoresh’s picture

dunebl’s picture

D9.1.5 and field_group 3.x-dev
I am using details and I have added the '#name' key everywhere in Details.php as per #16 and #17 without luck.

Here is the core function producing the error:

 public static function reduceOrder($array, $a) {
    $array = !$array ? [] : $array;
    if ($a['name']) {
      $array[] = $a['name'];
    }
    if (!empty($a['children'])) {
      uasort($a['children'], ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']);
      $array = array_merge($array, array_reduce($a['children'], [static::class, 'reduceOrder']));
    }

    return $array;
  }

My feeling is that if ($a['name']) {..} should be if ($name=$a['name']??FALSE){$array[]=$name;} or like this. This is because I can't think of a case where $a['name'] is set and not TRUE
Could it be a core bug?

I my case the 'name' key was not set (only $a['children'])

coaston’s picture

any update?

khaled_webdev’s picture

I bypassed by replacing
if ($a['name']) {
by
if (!empty($a['name'])) {

I used this fix to hide error, i continued on editing and after saving, i restored

peonboyos’s picture

StatusFileSize
new565 bytes

Ive match the patch for this comment. #21

eahonet’s picture

@peonboyos I used your patch in #22. Took me a second to realize to apply it to core and not field_group. It did get rid of the error. The site seems to functioning well so far with this core change.

ralkeon’s picture

Project: Field Group » Drupal core
Version: 8.x-3.0-rc1 » 9.2.x-dev
Component: Miscellaneous » field system
Status: Closed (duplicate) » Needs review

Seems that this issue is still present, it's not a duplicate and the #22 patch it's working for me. I hope I edited the issue metadata correctly. Re-opening the issue.

quotientix’s picture

+1 and thanks for the patch - works for me!

joshmiller’s picture

Problem experienced for me on 9.2.7 as well, while creating a new field_group. Patch applied to Drupal core without fuss. Error went away.

kristen pol’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Bug Smash Initiative
StatusFileSize
new297.26 KB
new219.83 KB

Thanks for the patch!

I tested with and without the patch (see screenshots). Code change is very simple and makes sense. Marking RTBC.

catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

This could use some test coverage.

danflanagan8’s picture

Version: 9.2.x-dev » 9.4.x-dev
Status: Needs work » Needs review
StatusFileSize
new2.19 KB

I took a crack at writing a unit test for this. It's pretty straightforward. No mocking or anything.

The third case is going to trigger a failure. I tried to make a "realistic" case by following #19:

I my case the 'name' key was not set (only $a['children'])

Changing version to 9.4.x too.

danflanagan8’s picture

Issue tags: -Needs tests
StatusFileSize
new2.74 KB
new565 bytes

The test failed at the right place with the right message so I'm removing the Needs tests tag.

Here's a patch that includes the fix from #22.

volker23’s picture

Applied patch from #30 without hassle on 9.2.10, error gone, seems to work as expected. Thanks!

heykarthikwithu’s picture

+1 patch #30, thanks for the patch.. works.

delacosta456’s picture

hi #30 looks to be ok for me too on

D8.9.20 thanks

joegl’s picture

Patch in #30 applied cleanly to our Drupal 9.2.9 site and resolved the warning/issue.

joegl’s picture

I believe the below has to do with our composer patch setup and not the patch itself. Please ignore below.

For anyone who does run into the issue I was having below see:
- https://github.com/cweagans/composer-patches/tree/1.x#allowing-to-force-...
- https://github.com/cweagans/composer-patches/issues/43

Scratch that. We applied the patch with the composer and the test file was placed in its own directory instead of being added to the field_ui module.

Instead of adding the new test file to: core/modules/field_ui/tests/...

It created the following path and file : core/b/core/modules/field_ui/tests/...

The change to the FieldUiTable.php file was applied cleanly in the correct directory.

joshmiller’s picture

Status: Needs review » Reviewed & tested by the community

Tests failed and passed as expected. Patch applies. Previous to tests was RTBC. Back to RTBC.

  • catch committed fbdb75e on 10.0.x
    Issue #3064890 by danflanagan8, mpp, mottihoresh, scott_euser, peonboyos...
catch’s picture

Version: 9.4.x-dev » 9.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 10.0.x, cherry-picked to 9.4.x and 9.3.x,thanks!

  • catch committed 26ec004 on 9.4.x
    Issue #3064890 by danflanagan8, mpp, mottihoresh, scott_euser, peonboyos...

  • catch committed 8278566 on 9.3.x
    Issue #3064890 by danflanagan8, mpp, mottihoresh, scott_euser, peonboyos...

Status: Fixed » Closed (fixed)

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