Site Builders can select non-active display modes in EntityReferenceEntityFormatter settings

Created on 4 June 2018, almost 7 years ago
Updated 17 February 2025, about 2 months ago

Problem/Motivation

When using the "Rendered Entity" formatter for an entity reference field, ll view modes will show up, even the ones for which there is no active display.

Scenario: Check if "Site Builders" can NOT select and use a disabled media view mode, under a referenced field in content/entity types

Given that we do have a media type "Image"
And we do have [size1, size2, size3, size4] media view modes for all media types
And we only enabled [size1, size2, size3] in the "custom display settings" for the "Image" media type
When we create a content type "Image Post"
And add an entity reference "field_image" to the "image" media type
And we go to the "Manage Display" for that content type
And we try to select a media's view mode for the "image" field in a content type's view mode
Then we should see [size1, size2, size3] in the drop-down list.

That is not the case at this time.
Site builders may select the not configured media view mode and it will show some not styled media

Proposed resolution

Only show enabled view modes for the used bundle.

Remaining tasks

Propose a patch for the right way to fix this issue

User interface changes

Only filter and show enabled view modes for a selected bundle.

API changes

N/A

Data model changes

It could be a config or an auto-discovery config

🐛 Bug report
Status

Closed: works as designed

Version

11.0 🔥

Component

entity system

Created by

🇯🇴Jordan Rajab Natshah Jordan

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.

  • 🇦🇺Australia acbramley

    Looking through how EntityReferenceEntityFormatter works and thinking about possible solutions I'm not sure this is actually achievable without some form of jankiness.

    Entity reference fields can allow multiple bundles. If I allow 2 bundles with different "active" view modes, how do we determine what to show in the view mode options? EntityDisplayRepository does have getViewModeOptionsByBundle (the formatter currently uses getViewModeOptions which returns all view modes for the entity type), but again we'd have to combine them for each bundle that's configured for the field, etc.

    Given configuring views is a site builder task, and the Views UI will show a preview, it's simple enough to swap the view mode if it doesn't look correct?

    I'm going to close this as works as designed given the length of time since it was last commented on it doesn't seem like a highly desirable change.

    Please feel free to reopen if you disagree.

  • 🇯🇴Jordan Rajab Natshah Jordan

    Noted;
    Thanks, Adam, for following up.
    We're implementing a custom-coded solution for this:

    Example: List of default ignored view modes.
    This is being handled using multiple _form_alter() hooks in forms.

    Maybe the allowed/ignored list could be stored within the same field-form config settings (for fields).

Production build 0.71.5 2024