Skip to content
Snippets Groups Projects
Commit 2e438914 authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Patch #830020 by chx, yched: field_get_display() does not get the entity.

parent df5714f5
No related branches found
No related tags found
No related merge requests found
......@@ -2165,6 +2165,7 @@ function hook_field_info_max_weight($entity_type, $bundle, $context) {
* - entity_type: The entity type; e.g. 'node' or 'user'.
* - field: The field being rendered.
* - instance: The instance being rendered.
* - entity: The entity being rendered.
* - view_mode: The view mode, e.g. 'full', 'teaser'...
*
* @see hook_field_display_ENTITY_TYPE_alter()
......@@ -2199,6 +2200,7 @@ function hook_field_display_alter(&$display, $context) {
* - entity_type: The entity type; e.g. 'node' or 'user'.
* - field: The field being rendered.
* - instance: The instance being rendered.
* - entity: The entity being rendered.
* - view_mode: The view mode, e.g. 'full', 'teaser'...
*
* @see hook_field_display_alter()
......
......@@ -142,7 +142,7 @@ function field_default_prepare_view($entity_type, $entities, $field, $instances,
foreach ($instances as $id => $instance) {
if (is_string($display)) {
$view_mode = $display;
$display = field_get_display($instance, $view_mode);
$display = field_get_display($instance, $view_mode, $entities[$id]);
}
if ($display['type'] !== 'hidden') {
$module = $display['module'];
......@@ -194,7 +194,7 @@ function field_default_view($entity_type, $entity, $field, $instance, $langcode,
// Prepare incoming display specifications.
if (is_string($display)) {
$view_mode = $display;
$display = field_get_display($instance, $view_mode);
$display = field_get_display($instance, $view_mode, $entity);
}
else {
$view_mode = '_custom_display';
......
......@@ -448,11 +448,13 @@ function field_view_mode_settings($entity_type, $bundle) {
* The field instance being displayed.
* @param $view_mode
* The view mode.
* @param $entity
* The entity being displayed.
*
* @return
* The display settings to be used when displaying the field values.
*/
function field_get_display($instance, $view_mode) {
function field_get_display($instance, $view_mode, $entity) {
// Check whether the view mode uses custom display settings or the 'default'
// mode.
$view_mode_settings = field_view_mode_settings($instance['entity_type'], $instance['bundle']);
......@@ -464,6 +466,7 @@ function field_get_display($instance, $view_mode) {
'entity_type' => $instance['entity_type'],
'field' => field_info_field($instance['field_name']),
'instance' => $instance,
'entity' => $entity,
'view_mode' => $view_mode,
);
drupal_alter(array('field_display', 'field_display_' . $instance['entity_type']), $display, $context);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment