field_view_field() is the API function to display a formatted value for a single field (outside of a fully rendered entity, which is the job of field_attach_view()).It is notably used to display field values in Views.

It invokes hook_field_attach_view_alter(), because this hook lets modules alter formatter render arrays before they are rendered, and fields displayed in Views should not bypass that.

However, the alter hook is not invoked in the exact same way than during field_attach_view(), which might cause warnings in modules implementing the hook :
- the incoming $output misses '#entity_type' and '#bundle' properties
- the $context misses a 'language' entry

For instance, displaying a View with fields while the (prototype) field_group.module in CCK HEAD is enabled raises warnings.

CommentFileSizeAuthor
field_view_field_warnings.patch1.56 KByched
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chx’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests