Problem/Motivation
When rendering entity reference field items (node, taxonomy_term, ...) it is impossible to override the view mode templates (node--teaser.html.twig, ...), meaning, although field wrappers can be controlled from the module, it does not provide sufficient markup control when rendering entities from entity reference field to fully remove HTML wrappers when rendering referenced field item content.
Steps to reproduce
Add an entity reference field to Manage Display and set the field Format to the Rendered entity. If rendered entity uses the twig template for the selected display mode (e.g., node--teaser.html.twig, ...) the template can add undesired wrapping markup.
Proposed resolution
Provide an option to remove item content wrappers when rendering entity reference filed item content, i.e., loop through field items, check for and override content #theme with no-wrappers template provided by fences module.
Remaining tasks
Review and community test the merge request.
User interface changes
Add Override Referenced Field Item Content Template Theme checkbox to Entity Reference type fields.

Data model changes
Update configuration schema.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | fences-Override-Referenced-Field-Item-Content-Template-Theme.png | 69.22 KB | martins.bruvelis |
Issue fork fences-3321665
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
martins.bruvelisComment #4
martins.bruvelisComment #5
anybodyThanks @martins.bruvelis, we'll have a look at this, as soon as the failing tests are fixed (NW for that).
@thomas.frobieter what do you think about this request? Does it make sense to you with your experience?
Comment #6
thomas.frobieterI think this is a pretty good idea! But for sure, it should be disabled by default.
Comment #7
anybodyThanks! :)
@martins.bruvelis some points for refinement then, as I think we will accept the additions as soon as everything is fine.
Please
Thanks a lot in advance, nice work!
Comment #8
martins.bruvelisComment #9
martins.bruvelisComment #10
martins.bruvelis@Anybody, regarding
Drupal 10 no longer has "stable" theme, replaced it with "stark" theme, resolved the tests failure.
OK, added a test to check if the default "stark" theme content wrapper element (article) is removed, when enabling the new setting.
Please, check the revised description.
Comment #11
martins.bruvelisAlso, when enabling the setting "No wrapping HTML for entity content", it is necessary to use the module Manage display to resolve the bug reported in the issue
Unable to remove "Author" and "Created" data from Entity Reference fields. The module Manage display allows to correctly hide/display all of the fiends, including, "Author" and "Created" fields.
Comment #12
anybody@martins.bruvelis I'm back here, sorry. Would you mind having a look at my comment in the MR and fix the conflicts? Then we should fix the broken test and review and test this once again!
Comment #13
martins.bruvelisReview needed (all patch related tests in OverrideEntityReferenceTest pass).
Comment #14
martins.bruvelis