0

Hoping someone can assist me please.

I am trying to display the value of a custom field in a bootstrap sub theme

I have created my node--testtype.html.twig template and that seems to work.

I'm trying to just show the content of one field, the machine name is field_classification.

When I use <h1>Classification: {{ content.field_classification.value }}</h1> the Classification displays as expected, but the value of my field_classification doesn't.

Can anyone see what I am doing wrong please as thought I d copied the correct code from what I have read?

  • Means you are only getting an empty <h1></h1>? – leymannx Apr 27 at 17:15
1

{{ content }} is a render array and does not have a .value, just use {{ content.field_name }}

You only need the .value when you want to print the raw values of an entity object like node, e.g. {{ node.field_my_integer.value }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy