Hi,

After updating to 7.x-1.3, when I access My Account & other pages, it randomly shows Notice: Undefined index: #view_mode in field_formatter_class_preprocess_field() (line 61 of public_html/sites/all/modules/field_formatter_class/field_formatter_class.module).

First I thought it was the bug of Field Formatter Class module. After reading this #1888604: Notice: Undefined index: #view_mode in field_formatter_class.module which gave me some clues, I checked through the codes of realname.module, and added

'#view_mode' => $view_mode,

to the array of line #176

 $account->content['realname'] = array(  
...
...

After that, the notice disappeared. I doubt if this is the solution. Kindly advise. Thanks

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

paulwdru created an issue. See original summary.

dbouman’s picture

I was getting this same issue when using Display Suite Extras with field templates enabled.

The code change worked for me. Here it is in patch form.

hass’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
Status: Active » Needs work
Issue tags: +Needs tests
Adrião Neves’s picture

That worked. Thanks!

mrtndlmt’s picture

That works for me!

jerrac’s picture

#2 patch removed my error as well.

Notice: Undefined index: #view_mode in ds_extras_preprocess_field() (line 1011 of /path/to/drupal/root/sites/all/modules/contrib/ds/modules/ds_extras/ds_extras.module).

Thanks!

donquixote’s picture

Could also be causing this issue in ds: #2261001: Notice: Undefined index: #view_mode in ds_extras_preprocess_field()

Patch looks reasonable to me and works.

donquixote’s picture

Also this change is needed:

  $account->content['realname'] = array(
-    '#entity_type' => 'custom',
-    '#bundle' => 'custom',
+    '#entity_type' => 'user',
+    '#bundle' => 'user',

And maybe the '#items' should get something more bullet-proof than array(TRUE).

There are many modules that want to mess with theme_field(). They all expect a specific format.

MrPaulDriver’s picture

Be good to see this committed

jmev’s picture

Seems similar to this issue: https://www.drupal.org/node/1928470#comment-7737419. Of course, field_empty_text is obsolete now, but the issue seems common.

I will say that this appeared for me only after a code push to dev server, and disappeared after simply visiting the display suite fields page (/admin/structure/ds/fields) and then returning to the original page it appeared on, as if the database was somehow updated/refreshed. I'm still applying the patch in the hopes that it never resurfaces to irritate the client.

I agree with MrPaulDriver on committing the patch.

ikeigenwijs’s picture

Status: Needs work » Needs review

#2 worked for us
#8 sounds logical but can have implications down the line for other modules

hass’s picture

Status: Needs review » Needs work

See #3

giupenni’s picture

#2 works for me!

trumanru’s picture

Status: Needs work » Reviewed & tested by the community

#2 work in my environment.

I think #8 should be addressed to another issue.

#3:
- tests passed
- 9 users (with me) approved the patch is working

The patch should be committed!

hass’s picture

Status: Reviewed & tested by the community » Needs work

Still no tests added.

g33kg1rl’s picture

This patch fixes the issue for me too.

ntym’s picture

I had same issue, but it's not the realname module bug.
Field_formatter_class module fixed that in last dev - https://www.drupal.org/project/field_formatter_class/issues/1939108

hass’s picture

Status: Needs work » Closed (duplicate)

Thanks for your info.

hass’s picture