I have a taxonomy term reference field attached to my user account.
I tried getting the value programatically in the same way as I get the value for text fields, but it doesn't work.
use Drupal\Core\Session\AccountProxyInterface; use Drupal\user\Entity\User; $account = User::load($account->id()); // Returns the correct value. $textfield = $account->get('field_textfield')->value; // Does not return the correct value. $termreference = $account->get('field_termreference')->value;
How am I supposed to get the value (name) of the referenced term programatically?