Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#16 | test_eva__Content____iccr-db.jpg | 76.36 KB | AaronBauman |
#16 | eva-hide_by_default-2024011-16.patch | 10.38 KB | AaronBauman |
|
Comments
Comment #1
nandwabee CreditAttribution: nandwabee commentedHave 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.
Comment #2
mstrelan CreditAttribution: mstrelan commentedUpdating 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.
Comment #3
mstrelan CreditAttribution: mstrelan commentedBTW I don't think this is actually possible using hook_fields_extra_fields().
Comment #4
mstrelan CreditAttribution: mstrelan commentedRelated core issue #1256368: Add 'visible' key to hook_field_extra_fields()
Comment #5
klonosRather 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.
Comment #6
AaronBaumanThis 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.
Comment #7
AaronBaumanThis 2-line patch will hide new EVAs by default.
Comment #9
AaronBaumanHere's the same patch against 2.x, along with an updated config so the test that will maybe pass?
Comment #11
AaronBaumanOne more try on the test.
Comment #13
ahebrank CreditAttribution: ahebrank commentedI 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.
Comment #14
gagarine CreditAttribution: gagarine as a volunteer commentedI believe the default should be consistent with Drupal other fields.
(Unfollowing this issue now has I don't use it anymore.)
Comment #15
AaronBaumanoooh, i like that idea.
I'll roll a patch for that.
Comment #16
AaronBaumanHere's a patch + test that adds a "hide by default" option to the EVA display.
Screenshot:
Comment #17
ahebrank CreditAttribution: ahebrank commentedOh, 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)?
Comment #18
AaronBaumanDo you know off-hand what the indicator for this would be?
Would I have to check the entity display config value directly?
Comment #19
ahebrank CreditAttribution: ahebrank commentedOff 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).Comment #20
AaronBaumanThinking 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."
Comment #21
ahebrank CreditAttribution: ahebrank commentedActually, maybe this is easier: how about hiding/disabling the setting unless the View display configuration is brand new?
Comment #22
AaronBaumanThe 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.
Comment #23
AaronBaumanBumping this
Comment #24
AaronBaumansemi-annual bump
Comment #25
liquidcms CreditAttribution: liquidcms commentedgoing 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).
Comment #26
AnybodyI'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.
Comment #27
SirClickalotI 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.
Comment #28
AaronBaumanbump