Extra field on entity used in a relation

Created on 25 January 2018, over 7 years ago
Updated 30 July 2025, about 1 month ago

When an extra field is added to an entity and this entity is used in a view relation, the entity provided to the "render_class" shoudn't be the view based entity but the related entity.

Steps to reproduce :

  1. Create a new content type "Test"
  2. Add a entity reference field and choose a node "Article"
  3. Add an extra field to the node "Article" with the hook_entity_extra_field_info
  4. Create the render class.
  5. Create a view base on content test
  6. Add a relation to the node Article
  7. Add the extra field created before.

Actually in the "render class", the parameter "$entity" passed is the current "Test" node instead of the related "Article".

Here is a patch to provide the correct one to the "render class".
Please note that views relation is not necessary required so for some items it can exists or not.
That's why in the "render class" the provided entity can be null.

The patch looks for the right relationship entity to use even if there is multiple same relations (for example if there is two entity reference fields to "Article" node)

πŸ› Bug report
Status

Needs work

Version

2.2

Component

Code

Created by

πŸ‡«πŸ‡·France klelostec

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡¦Ukraine bohart Lutsk, Ukraine

    Changed the version of this issue. Version 2.2.0 is now released, which means new developments and disruptive changes should be targeted against the 2.2.x development branch.

    Merge requests from the community will be incredibly welcome.
    Note: Only GitLab merge requests (not *.patch files) are reviewed by the currently active maintainer.

    Thanks!

Production build 0.71.5 2024