I have a User Entity class that contains one-to-many property "transactions" that holds the transactions of that particular user.
use Sonata\UserBundle\Entity\BaseUser as BaseUser;
class User extends BaseUser
{
//...//
/*
* @ORM\OneToMany(targetEntity="Transaction", mappedBy="user")
*
*/
protected $transactions;
//...//
}
In the backend i have the userAdmin class that extends the sonata admin class
/**
* @param \Sonata\AdminBundle\Datagrid\ListMapper $listMapper
* @return void
*/
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->add('id')
->addIdentifier('username')
->add('transactions')
;
}
If i do this i get the following error:
An exception has been thrown during the rendering of a template ("You must define an
associated_tostring
option or create aProject\MyBundle\Entity\Transaction::__toString
method to the field option transactions from service gd_admin.customer_details is ") in SonataDoctrineORMAdminBundle:CRUD:list_orm_one_to_many.html.twig at line 17.
Not understanding how do i provide a link to the user transactions in the User Listing page. Any help would be really greatful.
Thanks.