我有一個用戶實體類,其中包含一對多的財產「交易」,持有該特定用戶的交易。Symfony2:如何在sonatabundle的configureListFields中添加一個到多個屬性字段?
在後臺我有一個擴展奏鳴曲管理類
/**
* @param \Sonata\AdminBundle\Datagrid\ListMapper $listMapper
* @return void
*/
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->add('id')
->addIdentifier('username')
->add('transactions')
;
}
的userAdmin類如果我這樣做,我得到以下錯誤:
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.
不理解怎麼辦我在用戶列表頁面中提供用戶交易的鏈接。任何幫助都會非常棒。
謝謝。