I have a content type that has an entity reference field. It's a content type for news articles with a field for tagging the article with taxonomy terms.
I'm attempting to access these terms in a block plugin, however I'm having difficulty. Getting other fields like text fields, and dates work just fine. For example
$node = \Drupal::routeMatch()->getParameter('node'); $node->get('body')->value
Successfully returns the contents of the node's body but when I use:
$node = \Drupal::routeMatch()->getParameter('node'); $tags = $node->get('field_tags')->value;
$tags comes up empty.
Does not display anything. I know it's in there somewhere though because when I use
I do see the tag id's in there.
Is there a way to display the value of an entity reference field for taxonomy terms, in a block plugin?