Closed (fixed)
Project:
Display Builder
Version:
1.0.x-dev
Component:
display_builder_entity_view
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
2 Feb 2026 at 14:34 UTC
Updated:
24 Jun 2026 at 10:55 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #3
pdureau commentedA first commit has been pushed, with some WIP proposal.
When the Entity ID is not known (for example, when working in entity view display), we are still rendering the placeholder.
When the Entity ID is known, we are executing
EntityViewBuilderInterface::buildComponents()and extracting the built extra field renderable.Nearly done, however:
EntityViewBuilderInterface::buildComponents()last parameter, we are stuck in an infinite loop: the entity display is rendered, which is rendering the extra field, which is executing entity display rendering, which is rendering the extra field...linksfor example.Also, user's
member_forhas not been tested yet.Comment #4
yannickooFYI it is still possible to use
hook_entity_view_alterto implement the rendering part for extra fields. It seems like it is possible to add new elements to the$buildrender array using that way.Comment #5
pdureau commentedI take it for rebase and to test Yannick proposal
Comment #6
pdureau commentedTested.
hook_entity_view_alteris triggered not at the best moment of the rendering pipeline:display_builder:placeholdercomponent byExtraFieldSource::getPropValue(). We can add some annotations in the renderable to identify it in the source tree and replace it by the renderable available inhook_entity_view_alter.Comment #8
yannickoo@pdureau since I was not able to add commits to your MR I have created a new one which is adjusting the extra field source plugin implementation ➡️ https://git.drupalcode.org/project/display_builder/-/merge_requests/230
Comment #10
pdureau commentedOK cool. I hide my branch and move back the issue to beta3 scope.
Comment #11
pdureau commentedHi Yannick,
I got a look on your proposal. I like a lot your are staying in
modules/display_builder_entity_view/src/Plugin/UiPatterns/Source/ExtraFieldSource.phpwithout spreading out the logic elsewhere.However, it doesn't work on my side.
$this->moduleHandler->invokeAll('entity_view', [&$build,$entity, $display, $view_mode ]);is returning a (nearly) empty render array, without the expected extra field.Also:
src/Plugin/display_builder/Island/BlockLibraryPanel.php?::settingsForm()can be removedComment #12
mogtofu33 commentedComment #13
yannickooThe current problem is that we can only get rendered extra fields that are provided via
hook_entity_view. The node and user module are doing this in their view builders which is hard to catch since we have this infinite loop when trying to just usebuildComponent.Any contrib module works without issues but the core extra fields are not provided like that :/
Comment #14
fmb commentedI like the way this is presented in Display Builder.
In order to use this patch, make sure that:
Should we allow the use of hook_ENTITY_TYPE_view()? What about the condition on $display->getComponent() ?
Comment #15
yannickooI agree with point #1 that we should allow that hook as well!
Comment #16
mogtofu33 commentedComment #17
mogtofu33 commentedComment #18
mogtofu33 commentedComment #19
yannickooHey Jean! It turned out that we had an infinite call which could be avoided in this commit. This was breaking all projects but is fixed with the latest changes.
Comment #20
pdureau commentedDiscussed with Jean... (a few weeks ago, so from memory...)
There are two kinds of extra fields...
Those hardcoded in view builders entity handlers:
For those, let's also do a specific, hardcoded, mechanism on our side.
Those based on
hook_ENTITY_TYPE_view:For those, let's manage theme with a clean, generic, solution.
Comment #21
mogtofu33 commentedTested with links (node and user) and contrib module Flag, addtoany, works fine!
Comment #22
mogtofu33 commentedComment #23
pdureau commentedTests
Links extra field in node (hardcoded in view builder entity handler):
{"#type":"html_tag","#tag":"span","lazy":{"#lazy_builder":["Drupal\\node\\NodeViewBuilder::renderLinks",["1","default","en",false,null]]}}"but no links. Is it normal?"Member for" extra field in user (based on
hook_ENTITY_TYPE_view):Test with an entity type without extra field (content block):
MR analysis
I agree with the removal of
modules/display_builder_entity_view/src/Plugin/UiPatterns/Source/ContentEntitySource.php, we have added it too soon, we have dedicated ticket to address this feature and we need to #3540247: Tidy source contexts in UI Patterns first. I just hope it will not break the display of too much people.metadataattribute, used inExtraFieldSource, is an undocumented feature of UI Patterns we will try to remove soon (see #3591167: Tidy metadata plugin attributes).Do we some dedicated kernel tests? Are the addition
display_builder_entity_view_test.moduleenough?Comment #24
mogtofu33 commentedContentEntitySourcewas an old test, it was a mistake of mine to commit it. It was not possible to use it it seems because on context. I've never seen it in ui, that's why I forgot to delete it sooner.The test is minimal, it was a bit tricky but I think it covers what's needed.
#lazy_builderis empty because it's lazy and will load on render, the render array is good, strange you have nothing... Keep in mind core links which is only 'read more' for node if no comments and is not in default/full but teaser. Enable comments to see if it works.Empty extra field in ui will be a follow up as it's not blocking or failing anything.
Comment #25
pdureau commentedThat's clear, and that's nice.
Oohhh! that must be the explanation.
OK, in a follow-up.
So, there are only 2 open topics to discuss before RTBC:
metadataattribute, used inExtraFieldSource, is an undocumented feature of UI Patterns we will try to remove soon (see #3591167: Tidy metadata plugin attributes) and I would advise not using it.Comment #26
yannickooJust dropping a static patch to avoid having floating MR patch file 😇
Comment #27
mogtofu33 commented