Ok, so I'm trying to populate a field based on the selection of a taxonomy term. I've mainly got it working thanks to this stack exchange article
use Drupal\taxonomy\Entity;
function module_entity_presave(EntityInterface $entity) {
if($entity->bundle() == "node_type"){
$bread_slice = $entity->get("field_taxonomy_term")->getString();
$bread_butter = "- Additional Text for Reasons";
$bread_title = $bread_slice." ".$bread_butter;
$entity->field_title->value = $bread_title;
//save is done automatically
}
}
The issue is that, the resulting code doesn't print the name/label of the term, but instead the tid. So, it ends up showing as "757 - Additional Text for Reasons" I barely know any php, but I know enough to get around. I suppose my issue is the fact I'm not getting the correct value from the taxonomy array, yet I'm unsure how. I've tried finding the correct value using some twig debugging, {{dd(data.taxonomy_term)}} but all the values for it show null. Please point me in the direction of how to solve this?