The example code within the hook uses 'visibility' key when the api seems to use 'visible'.

function hook_field_extra_fields_display_alter(&$displays, $context) {
  if ($context['entity_type'] == 'taxonomy_term' && $context['view_mode'] == 'full') {
    $displays['description']['visibility'] = FALSE;
  }
}

Implementing the following:

function somemodule_field_extra_fields_display_alter(&$displays, $context) {
  if ($context['entity_type'] == 'user' && $context['view_mode'] == 'display') {
    $displays['summary']['visible'] = FALSE;
  }
}

Is called, and changes the array as can be confirmed by running

debug(field_extra_fields_get_display('user', 'user', 'display'));

but when viewing a user/#/view page the history is still visible.

CommentFileSizeAuthor
#2 1097972-hook-example-code.patch1.27 KBboombatower
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

boombatower’s picture

Title: hook_field_extra_fields_display_alter() does not appear to work and has incorrect documentation » hook_field_extra_fields_display_alter() incorrect example code

Heh, view_mode == 'full' should be the code. Only getting called since I was calling it bellow.

So only incorrect example code.

boombatower’s picture

Assigned: Unassigned » boombatower
Status: Active » Needs review
FileSize
1.27 KB

Assume we start the 'ol commit to 8.x and backport to 7.x?

yched’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Documentation

Correct.

Dries’s picture

Version: 8.x-dev » 7.x-dev

Committed to my local repository. Will be pushed later today. Moving to D7.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 7.x. Thanks!

Status: Fixed » Closed (fixed)
Issue tags: -Documentation

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