The following warning happens:
Notice: Undefined index: name in _field_ui_reduce_order() (line 72 of modules/field_ui/field_ui.admin.inc).

I am certain a 3rd party module is involved in my case with the form, but I am not certain which one.

The cause of the warning is that:

<?php
  if ($a['name']) {
    $array[] = $a['name'];
  }
?>

is no the same as:

<?php
  if (isset($a['name'])) {
    $array[] = $a['name'];
  }
?>

This can be found in the file: modules/field_ui/field_ui.admin.inc on line #72 as mentioned by the warning.
Immediately below the if case on line #72 is:

<?php
  if (!empty($a['children'])) {
    uasort($a['children'], 'drupal_sort_weight');
    $array = array_merge($array, array_reduce($a['children'], '_field_ui_reduce_order'));
  }
?>

So, perhaps this is an oversight and they meant to have:

<?php
  if (!empty($a['name'])) {
    $array[] = $a['name'];
  }
?>

Given that this warning might happen as a result of a api mistake by a 3rd-party module, I am asking first for confirmation that the field_ui is or is not supposed to be checking if !empty instead of if variable

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yched’s picture

Category: support » bug
Status: Active » Postponed (maintainer needs more info)
FileSize
910 bytes

field_ui_table_pre_render() internally builds a tree structure of table rows to determine rendering order.
Each entry in the tree structure is supposed to have a 'name', the root of the tree just has an empty name. So the check for if ($a['name']) instead of if (isset($a['name'])) is intentional.

I'm not sure what can lead to one entry not having a name. Most probably caused by a contrib module, but figuring out who's at fault and what to fix (core or the contrib module) requires some investigation.

Could you try the attached debug patch and post the resulting output (possibly big, please put that in a txt file) ?

thekevinday’s picture

Status: Postponed (maintainer needs more info) » Fixed

Thanks for your time, but with all of the module updates lately the problem stopped appearing at some point.
I am going to assume this problem was with a 3rd party module and was resolved in said module.

I will re-open if I manage to see this bug again and use your patch do debug.

Status: Fixed » Closed (fixed)

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

videographics’s picture

I don't know how helpful this will be but I got this after installing Drupal Commerce (Beta-2) and the associated required modules. The error appeared while I was setting up some fields that had been previously defined for other node types.

swentel’s picture

Status: Closed (fixed) » Active

Hi Yched, cross referencing to #1176454: Moving fieldsets into another region leaves children behind where you can find steps to reproduce with the field_group module (2 ways). Posting the error message from the patch above. Note, the output comes from the ajax error popup


An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /system/ajax
StatusText: OK
ResponseText: Array
(
[body] => body
[field_tags] => field_tags
[field_image] => field_image
[dynamic_field] => dynamic_field
[title] => title
[links] => links
[comments] => comments
[node_link] => node_link
[author] => author
[post_date] => post_date
[ds_user_picture] => ds_user_picture
[group_article_group] => group_article_group
[_add_new_group] => _add_new_group
)
Array
(
[left] => Array
(
[] => Array
(
[name] => 
[children] => Array
(
[group_article_group] => Array
(
[children] => Array
(
[field_image] => Array
(
[name] => field_image
[weight] => 11
)
)
)
)
)
)
[right] => Array
(
[] => Array
(
[name] => 
[children] => Array
(
[group_article_group] => Array
(
[name] => group_article_group
[weight] => 0
)
)
)
)
[hidden] => Array
(
[] => Array
(
[name] => 
[children] => Array
(
[body] => Array
(
[name] => body
[weight] => 9
)
[field_tags] => Array
(
[name] => field_tags
[weight] => 10
)
[dynamic_field] => Array
(
[name] => dynamic_field
[weight] => 6
)
[title] => Array
(
[name] => title
[weight] => 7
)
[links] => Array
(
[name] => links
[weight] => 8
)
[comments] => Array
(
[name] => comments
[weight] => 5
)
[node_link] => Array
(
[name] => node_link
[weight] => 4
)
[author] => Array
(
[name] => author
[weight] => 1
)
[post_date] => Array
(
[name] => post_date
[weight] => 2
)
[ds_user_picture] => Array
(
[name] => ds_user_picture
[weight] => 3
)
[_add_new_gr...\" type=\"text\" id=\"edit-fields-add-new-group-group-name--2\" name=\"fields[_add_new_group][group_name]\" value=\"\" size=\"15\" maxlength=\"128\" class=\"form-text\" \/\u003e \u003cspan class=\"field-suffix\"\u003e\u003c\/span\u003e\u0026lrm;\u003c\/span\u003e\n\u003cdiv class=\"description\"\u003eGroup name (a-z, 0-9, _)\u003c\/div\u003e\n\u003c\/div\u003e\n\u003c\/td\u003e\u003ctd\u003e\u003cdiv class=\"form-item form-type-select form-item-fields--add-new-group-format-type\"\u003e\n \u003cselect id=\"edit-fields-add-new-group-format-type--2\" name=\"fields[_add_new_group][format][type]\" class=\"form-select\"\u003e\u003coption value=\"div\"\u003eDiv\u003c\/option\u003e\u003coption value=\"fieldset\" selected=\"selected\"\u003eFieldset\u003c\/option\u003e\u003coption value=\"tabs\"\u003eVertical tabs group\u003c\/option\u003e\u003coption value=\"tab\"\u003eVertical tab\u003c\/option\u003e\u003coption value=\"htabs\"\u003eHorizontal tabs group\u003c\/option\u003e\u003coption value=\"htab\"\u003eHorizontal tab item\u003c\/option\u003e\u003coption value=\"accordion\"\u003eAccordion group\u003c\/option\u003e\u003coption value=\"accordion-item\"\u003eAccordion item\u003c\/option\u003e\u003c\/select\u003e\n\u003c\/div\u003e\n\u003c\/td\u003e\u003ctd\u003e\u003c\/td\u003e\u003ctd\u003e\u003c\/td\u003e \u003c\/tr\u003e\n\u003c\/tbody\u003e\n\u003c\/table\u003e\n\u003c\/div\u003e","settings":null},{"command":"insert","method":"prepend","selector":null,"data":"","settings":null}]
swentel’s picture

Status: Active » Closed (works as designed)

Ok closing this, looks like I had a version of Drupal core which didn't work fine - works ok on 7.2 now.

DrupalDan’s picture

Version: 7.0 » 7.18
Status: Closed (works as designed) » Active

Notice: Undefined index: name in _field_ui_reduce_order() (line 81 of /mysite/modules/field_ui/field_ui.admin.inc).

swentel’s picture

Status: Active » Postponed (maintainer needs more info)

What's the setup ? In case you're using field group or ds, move it to it's respective queue.

DrupalDan’s picture

Hi swentel, I'm using field group.

swentel’s picture

Project: Drupal core » Field Group
Version: 7.18 » 7.x-1.x-dev
Component: field_ui.module » Code
Status: Postponed (maintainer needs more info) » Active
jdesrig’s picture

I am getting this issue when I try to create a tab group in the Display Suite 'manage display' section. I get the following error:
LOCATION http://localhost:82/ran-bookstore/admin/structure/types/manage/product/d...
REFERRER http://localhost:82/ran-bookstore/admin/modules
MESSAGE Notice: Undefined index: name in _field_ui_reduce_order() (line 81 of C:\EasyPHP-5.3.8.1\www\ran-bookstore\modules\field_ui\field_ui.admin.inc).

I am using:
Drupal 7.18
PHP 5.3.8 VC9
Apache 2.2.21 VC9
MySQL 5.5.16

The group is created (I gave it the name book_info) but it doesn't display any horizontal tabs. What is the issue here?

groovedork’s picture

/* Nevermind.. misunderstood the question */

nils.destoop’s picture

Is this issue still occuring on latest version?

Daniel Wentsch’s picture

@zuuperman: yes, I'm still getting this error on 7.x-1.x-dev from 2013-Sep-15

maximpodorov’s picture

I'm getting this problem also in the latest 7.x-1.x-dev when I move "Add new field" line in a previously created group.

ejustice’s picture

If you are using field group you might check out comment #18 in this thread. I haven't had a chance to test it myself, but wanted to pass this on before I forgot. https://drupal.org/comment/5835954#comment-5835954

giupenni’s picture

Issue summary: View changes

very annoying bug, I'm frustrated.
I can't use correctly Field Group and Displya Suite

nils.destoop’s picture

Status: Active » Closed (duplicate)
maximpodorov’s picture

Why do you close it without referencing any similar issue?

Luca Cattaneo’s picture

Maybe this can help someone.
I was getting this error, then I discover that the "Add new field" form was not in his original position (I wasn't using it).
It was positioned in a field group. Moving it to the original position, the error disappeared.

katrien_w’s picture

Issue solved for me on a custom content type with #20, in my case it was the "Add existing field" that was misplaced in a group. Just pulled it out of the group, at the bottom again, and the notice dissapears. Thanks!

hagit’s picture

Thank you Luca Cattaneo(#20)!! Issue solved for me

rzgragg’s picture

Thanks Luca #20

GarChris’s picture

#20 solved it for me. Thanks Luca!

donquixote’s picture

Status: Closed (duplicate) » Active

Why do you close it without referencing any similar issue?

Exactly.
Reopening.
If someone still thinks this is a duplicate, please link to the respective issue, and add it in "Related issues".

Christian DeLoach’s picture

I was getting the same error as well. To troubleshoot the offending field, I temporarily added the following code to _field_ui_reduce_order() in field_ui.admin. This assumes you have the Devel module installed.

function _field_ui_reduce_order($array, $a) {
  $array = !isset($array) ? array() : $array;
 
  # Temporarily add the following code:
  if (!isset($a['name'])) {
    dpm($a);
  }
  
  if ($a['name']) {
    $array[] = $a['name'];
  }
  if (!empty($a['children'])) {
    uasort($a['children'], 'drupal_sort_weight');
    $array = array_merge($array, array_reduce($a['children'], '_field_ui_reduce_order'));
  }
  return $array;
}

I'm using Display Suite and Field Groups. Turns out, the offending field was somehow indented in the Manage Fields UI as if it were a child of a field group. Moving the field left and resaving the display didn't seem to fix the issue. I had to move the field around a few times into other field groups before if finally fixed itself.

mastoll’s picture

@Christian DeLoach, what WAS the offending field? And what does your temporary code do to reveal the offending field?
Unfortunately, unlike #20 or #21, my Add Existing and Add New fields are right where they should be.
Maybe there's another field out of place in my case.

hgoto’s picture

I met the same issue. In my case,

- A field group group_foo is enabled and displayed. And it has some fields like field_a, field_b and field_c.
- And somehow field_a gets hidden though it's belongs to the displayed group group_foo. (I didn't notice when it occurred.)
- Then, the field field_a is in the hidden group and indented. And the warning message shows up.

I don't have any idea how that occurred (I use Features module for the project and it may be related) but I found that moving the field field_a to any proper place fixed the issue. I hope this helps.

Christian DeLoach’s picture

@mastoll, sorry for the delayed response. What I meant by "offending field" is that one of the CCK fields triggered the error depending upon the field's placement. Instead of "troubleshoot", I should have used "identified" because that is the point of my small, temporary script change; to identify which field is throwing the error and correct the field's placement/position. As I mentioned in my previous post, the field appears to be a child of a group that doesn't exist. It's indented like it were a child of a group, but does not fall under a field group parent - at least not one that was visible. Attempts to resolve the problem required multiple attempts to move the field around, however, since I can't replicate the problem, I can't replicate the solution.

xaa’s picture

same warning here (on view mode teaser with DS). Here the issue was simply solved by deleting a fieldgroup item "disabled".

candelas’s picture

I also had today this problem and solved deleting the field item. The notice appeared after rebuilding permissions. By the way, thanks for the module :)

ExTexan’s picture

I also had this error. It was showing twice, after I had added two field groups. I fixed it by deleting and re-adding the groups.

The first time I added the groups, I had dragged them to where I wanted them. The second time, I did everything in separate steps... add - save - drag - save - move fields in groups - save.

GuyPaddock’s picture

This can happen if you try to create a field group, drag it into place, and then move fields under it, THEN save (i.e. you do all three in one save).

If you save right after creating the field group, and then drag it into place, this doesn't happen.

Rob C’s picture

This occurs for me if i create a field group, add a field, then save, then drag the field to disabled while maintaining the weight (so it floats to the right a bit, like it would when actually inside a group). See the attachment for how it looks in the UI.

If you then load the page, the group will be empty for that field that still thinks it's inside a group and presto:

Notice: Undefined index: name in _field_ui_reduce_order() (line 81 of modules/field_ui/field_ui.admin.inc).

Can't reproduce it with fields at this time, but fields that i had disabled previously still have this issue. After reordering then and saving the form the error seems to be gone. So it's a bug, but how to solve this? Would have to test all fields in an update hook and make sure they do not contain any field group attributes/weights/positions when they are disabled.

sime’s picture

Status: Active » Closed (won't fix)

Workaround in #33 is consistent across a number of issues (if unfortunate), and marking this won't fix for aging D7 branch.