In core/modules/field/field.api.php there's a mistake in hook_field_extra_fields_alter() example. A key level is missed (['form'] or ['display']).

The function should be:

/**
 * Alter "pseudo-field" components on fieldable entities.
 *
 * @param $info
 *   The associative array of 'pseudo-field' components.
 *
 * @see hook_field_extra_fields()
 */
function hook_field_extra_fields_alter(&$info) {
  // Force node title to always be at the top of the list by default.
  foreach (node_type_get_types() as $bundle) {
    if (isset($info['node'][$bundle->type]['form']['title'])) {
      $info['node'][$bundle->type]['form']['title']['weight'] = -20;
    }
  }
}

Comments

claudiu.cristea’s picture

Status: Active » Needs review
StatusFileSize
new1.03 KB

Attached a patch.

claudiu.cristea’s picture

Title: Fix doxygen for hook_field_extra_fields_alter() » Fix hook_field_extra_fields_alter() example code
yched’s picture

Status: Needs review » Reviewed & tested by the community

That's correct. Thanks !

catch’s picture

Version: 8.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)
Issue tags: +Needs backport to D7

Thanks!

Committed/pushed to 8.x. Will need a re-roll for 7.x

claudiu.cristea’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new1 KB

Patch for 7.x.

yched’s picture

Status: Needs review » Reviewed & tested by the community
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Nice catch! Committed and pushed to 7.x. Thanks!

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