referencedEntities cannot be used in Twig

Created on 9 September 2016, over 8 years ago
Updated 16 January 2022, almost 3 years ago

I have a Entity reference field within my content type. However I am unable to get the items in my template due to the Twig sandbox restrictions.

Twig_Sandbox_SecurityError: Calling "referencedEntities" method on a "Drupal\Core\Field\EntityReferenceFieldItemList" object is not allowed

If this was renamed / another method for getReferencedEntities, they could be used with the templates.

Or is there another way that I'm not aware of?

💬 Support request
Status

Closed: outdated

Version

9.3

Component
Theme 

Last updated 6 minutes ago

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States ddavisboxleitner

    If anyone else comes to this page and decides to add a 'twig_sandbox_whitelisted..' variable to their project, please note that the names of these variables has changed in Drupal 9.1

    See https://www.drupal.org/node/3162897

    twig_sandbox_whitelisted_classes is replaced with twig_sandbox_allowed_classes
    twig_sandbox_whitelisted_methods is replaced with twig_sandbox_allowed_methods
    twig_sandbox_whitelisted_prefixes is replaced with twig_sandbox_allowed_prefixes

Production build 0.71.5 2024