How To Get A Title Of The Referenced Entity

Tim Kamanin
Angry at Drupal
Published in
1 min readJan 31, 2018

So, I have a node that has an entity reference field field_book that points to another node (obviously, a Book node).

So now I want to get a title of the referenced book node. How do I do that?

As usual with Drupal, it’s as simple (;) as:

$entity->field_book->entity->getTitle()

Tadam!

--

--