I have a table ‘comment’, investigation that has a field referencing another table ‘sf_guard_user’. At the moment when I put
<?php echo $investigationComment->getUserId() ?>
I get the id value of the foreign table row. I want to be able to get the name field value.
Somewhere else in my project I was able to omit id from getUserId() and then put->getName() and it brought me that field value, but for this it’s not doing it for some reason. How can I get the name value for the foreign key row?
Just get the relation object first and then call for any property of that relation.
This will work if you defined an alias ‘User’ in your relation like this:
or