特定のユーザーのトランザクションを保持する 1 対多のプロパティ「トランザクション」を含むユーザー エンティティ クラスがあります。
use Sonata\UserBundle\Entity\BaseUser as BaseUser;
class User extends BaseUser
{
//...//
/*
* @ORM\OneToMany(targetEntity="Transaction", mappedBy="user")
*
*/
protected $transactions;
//...//
}
バックエンドには、sonata admin クラスを拡張する userAdmin クラスがあります。
/**
* @param \Sonata\AdminBundle\Datagrid\ListMapper $listMapper
* @return void
*/
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->add('id')
->addIdentifier('username')
->add('transactions')
;
}
これを行うと、次のエラーが発生します。
SonataDoctrineORMAdminBundle:CRUD:list_orm_one_to_many.html.twig の 17 行目で、テンプレートのレンダリング中に例外がスローされました ("You must define an
associated_tostring
option or create a method to the field option transactions from service gd_admin.customer_details is ")。Project\MyBundle\Entity\Transaction::__toString
ユーザー リスト ページでユーザー トランザクションへのリンクを提供する方法がわかりません。どんな助けでも本当に素晴らしいでしょう。
ありがとう。