When you create a EVA view it will add the "EVA field" on every display of the node. To be consistent with drupal core it should only add the field on the "default" display. In some situation it can even create infinity loop if you use EVA to display the same node type than the one you attach to.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nandwabee’s picture

Have you tried using it together with Display Suite? Works for me because you can create several custom displays for your node. An additional feature of Display suite is that you can have a unique display per node.

mstrelan’s picture

Title: Do not display the eva field on every node display » EVA field should default to hidden on view modes other than default

Updating the title to be more accurate. EVA can apply to any entity type, and it is really only the default settings that need to change.

@nandwabee - while that will solve the problem it involves manual intervention and is annoying if you have a lot of content types.

mstrelan’s picture

BTW I don't think this is actually possible using hook_fields_extra_fields().

mstrelan’s picture

klonos’s picture

Title: EVA field should default to hidden on view modes other than default » Allow selecting to which bundle displays the EVA field should be attached to - default to only the default display.
Category: bug » feature
Status: Active » Postponed

Rather then assuming that attaching to the default display only is what "most people" would want, we should allow them to choose the displays per bundle. You see, in my use case I had the need to only exclude one of the four displays of a chosen bundle. So, the trouble was less for me the way things are right now.

If I understand things correctly, we are waiting on #1256368: Add 'visible' key to hook_field_extra_fields(). Right? So, postponing on that.

AaronBauman’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Category: Feature request » Bug report
Issue summary: View changes
Status: Postponed » Active

This issue persists into 8.x

The current situation, where a new EVA makes itself visible for all displays of all entities to which its attached, is a bug.
A new field (or psuedo-field) should be hidden upon creation.

AaronBauman’s picture

Status: Active » Needs review
FileSize
817 bytes

This 2-line patch will hide new EVAs by default.

Status: Needs review » Needs work

The last submitted patch, 7: eva-hide_by_default-2024011-7.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

AaronBauman’s picture

Version: 8.x-1.x-dev » 8.x-2.x-dev
Status: Needs work » Needs review
Issue tags: +Needs tests
FileSize
1.54 KB

Here's the same patch against 2.x, along with an updated config so the test that will maybe pass?

Status: Needs review » Needs work

The last submitted patch, 9: eva-hide_by_default-2024011-9.patch, failed testing. View results

AaronBauman’s picture

Status: Needs work » Needs review
FileSize
2.22 KB

One more try on the test.

Status: Needs review » Needs work

The last submitted patch, 11: eva-hide_by_default-2024011-11.patch, failed testing. View results

ahebrank’s picture

I agree that it's not a great idea to show EVAs on all all display modes when attaching to an entity, but pseudofields play by different rules and it looks like visible = TRUE is the default. EVAs have behaved like this for a long time so it'd be a tough breaking change (the tests failing are a good clue that this really does change the behavior quite a bit).

However, I wonder if something like a global configuration flag on the module might be used to force visible = FALSE for users that want this behavior. But I'm hesitant about that as well since there aren't currently any other module configuration items. It'd be added complexity and also be a bit obscure for most users.

In short, conditionally modifying the behavior as suggested in this issue might be OK, but the default probably needs to stay the ways it's been.

gagarine’s picture

In short, conditionally modifying the behavior as suggested in this issue might be OK, but the default probably needs to stay the ways it's been.

I believe the default should be consistent with Drupal other fields.

(Unfollowing this issue now has I don't use it anymore.)

AaronBauman’s picture

Title: Allow selecting to which bundle displays the EVA field should be attached to - default to only the default display. » Expose a global setting to hide new EVA fields by default
Assigned: Unassigned » AaronBauman
Category: Bug report » Feature request
Status: Needs work » Needs review

However, I wonder if something like a global configuration flag on the module might be used to force visible = FALSE for users that want this behavior

oooh, i like that idea.
I'll roll a patch for that.

AaronBauman’s picture

Title: Expose a global setting to hide new EVA fields by default » Expose a display setting to hide new EVA fields by default
Issue tags: -Needs tests
FileSize
10.38 KB
76.36 KB

Here's a patch + test that adds a "hide by default" option to the EVA display.

Screenshot:
Screenshot of "hide by default" setting on views editing UI

ahebrank’s picture

Oh, interesting -- I was thinking about module config, but config on the display makes sense and is more visible. Can the message emphasize that this is a one-time deal and only affects initial attachment (or maybe the setting should even disappear or disable itself if the attached entity's display config has been modified already)?

AaronBauman’s picture

maybe the setting should even disappear or disable itself if the attached entity's display config has been modified already

Do you know off-hand what the indicator for this would be?
Would I have to check the entity display config value directly?

ahebrank’s picture

Off the top of my head, look through all the core.entity_display_view.TYPE.BUNDLE.* configs and check to see if the EVA is toggled the same in hidden section for every display config (or keyed TRUE in default and FALSE elsewhere? -- not sure about the nuances of how this gets set initially).

AaronBauman’s picture

Thinking this through... seems pretty impractical to account for all the possible variants to conditional display this setting.
Especially if the user changes the bundle / entity while editing the view.

How about just adding a note to the description text, like so?
"If enabled, new EVA fields will be added to the "hidden" region of entity displays. Otherwise, EVA fields will be added to the main content region of all attached entity displays. NOTE: Changing this setting has no effect if the field has already been added to the entity display."

ahebrank’s picture

Actually, maybe this is easier: how about hiding/disabling the setting unless the View display configuration is brand new?

AaronBauman’s picture

The best / only reliable way I can see to determine whether the EVA is a new display is to call View::load on the current view and see if the display is there.
Does that seem reasonable?
I don't see any isNew() or similar method on Display.

AaronBauman’s picture

Bumping this

AaronBauman’s picture

semi-annual bump

liquidcms’s picture

going to try out the simple patch from #11; as i dont think the later patch (to make it configurable) is correct approach. It should be disabled by default - always. As i believe core does when adding new field.

if it was going to be a config option; then the option should be set by default (as people will miss it and then when the view is saved you now have that field showing up on a 100 different view modes that need to be manually cleaned up).

Anybody’s picture

I'd vote to NOT add that option, but as written above, be compliant with Core and only show it on default. Everything else should be done manually, like with other fields added. Kept simple and consistent.

SirClickalot’s picture

I too agree that EVA should behave exactly a core; it SHOULD add the field to the Default view mode but SHOULD NOT not add it as 'active' to any others automatically. I hadn't realised that this rather long-standing thread existed so I put down my thoughts in a duplicate issue today which I will shortly close if there appears to any action with this one.

As site builder who uses EVA here, there, and everywhere, I firmly belive that this go inot the next release or ASAP afterwards.

Thanks all.

AaronBauman’s picture

bump