Make the Frontenduser a Property of your Model
This is my prefered solution to this. You have already a Ceator in your Coupon Model which seems to be only an integer value. You can make this a real relation to a fe_user.
Model:
/**
* @var Tx_Extbase_Domain_Model_FrontendUser
*/
protected $creator;
/**
* @param Tx_Extbase_Domain_Model_FrontendUser $creator
* @return void
*/
public function setCreator(Tx_Extbase_Domain_Model_FrontendUser $creator) {
$this->creator = $creator;
}
/**
* @return Tx_Extbase_Domain_Model_FrontendUser
*/
public function getCreator() {
return $this->creator;
}
TCA: In the TCA-Configuration of your coupon table you change the creator column to
...
'creator' => array(
'label' => 'your/label/from/locallang.xml',
'config' => array(
'type' => 'select',
'foreign_table' => 'fe_users'
)
),
...
After this you can set a hole FrontendUser object to that coupon of yours. This will also work with your existing coupons because in the db still only the uid of the fe_user is stored. Only Typo3 (via TCA) and extbase (via model) are told that this is a relation to fe_users. So $coupon->getCreator() returns a FrontendUser now. But you dont have to call this in your controller, just pass your $coupons to the view. You can access the username of a creator in Fluid with
{coupon.creator.username}