I have a Views fields twig template where I want to print the Views fields values manually.

For example, using: {{ fields.body.content }}

But this only works if the Views field is not excluded from the display.

Is there a way for me to print Views fields values if they are hidden (excluded from display)?


You shall do it like this:

{{ row._entity.field_myfield.value }}

| improve this answer | |
  • That doesn't work for me. I tried and got a WSOD error that logged "e Exception: Object of type Drupal\Core\Field\FieldItemList cannot be printed. in Drupal\Core\Template\TwigExtension->escapeFilter() (line 465 of /PATH/web/core/lib/Drupal/Core/Template/TwigExtension.php)." – quantumized Oct 16 '18 at 15:54
  • Try to kint fields, do you see the field you wanna render? – user72672 Oct 16 '18 at 15:55
  • {{ kint(fields) }} does not output the variables for hidden Views fields. – quantumized Oct 16 '18 at 15:59
  • Are you in the default view template ? – user72672 Oct 16 '18 at 16:00
  • I'm using the fields template (views-view-fields--VIEW_NAME--page.html.twig – quantumized Oct 16 '18 at 16:02

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.