0

I am using the following code to render a paragraph entity in a twig template: {{ content.entity_name}}

A second template renders the paragraph's fields correctly using:

<h2>{{ content.nav_title }}</h2>

The problem is it showing the label even when set to "visually hidden" and when set to label "hidden" it doesn't display the content at all.

Display settings

For example, it should render:

<h2>Example Option Two</h2>
<h2>Example Option Two</h2>

But when set to label "visually hidden" instead it renders (with extra spaces):

Entity Name Label



<h2>Example Option Two</h2>
<h2>Example Option Two</h2>

Finally, when set to label: "hidden" it renders (correct number of items but no content or markup from template):

{ item.content }}
{ item.content }}
  • You are missing a brace here, it should be {{ item.content }}. – Kevin Jan 11 at 18:38
  • It looks like you have the field label set to "Hidden". So, this means the label won't show up in the "field.html.twig" template level. It seems the the "Entity Name Label" is coming from some parent template. I'd recommend turning on twig debugging. (in services.yml set twig.config debug: true ). Then when viewing you web source in your browser you will be able to identify exactly where the unwanted text is coming from. (or you can at least include that info in your question). – sdmeyers Jan 11 at 20:54
  • @kevin that is the rendered content not my code that missing a brace. – Sam Jan 12 at 2:25

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.