php - Extending SonataAdmin User with ManyToMany field -
i trying extend sonatauserbundle's user add new manytomany relationship existing entity.
i extended user based on answer found here - extending sonata user bundle , adding new fields
user.php
/** * @orm\manytomany(targetentity="foo\barbundle\entity\pledge", inversedby="pledgedusers") **/ private $pledgedon; // (...) generated getters , setters here
pledge.php
/** * @orm\manytomany(targetentity="foo\userbundle\entity\user", inversedby="pledgedon") **/ private $pledgedusers; // (...) generated getters , setters here
the first thing noticed when sync schema, creates 2 pivot tables, instead of one: pledge_user
, user_pledge
. tried adding @orm\jointable
in, that's changing name of one. when add same @orm\jointable
both, 'table exists' error.
when try access user list in admin, getting big sql error
an exception occurred while executing 'select count(distinct u0_.id) sclr0 user u0_ left join fos_user_user_group f2_ on u0_.id = f2_.user_id left join fos_user_group f1_ on f1_.id = f2_.group_id': sqlstate[42703]: undefined column: 7 error: column u0_.id not exist
i sure simple, smacking head finding source of problem. did miss?
full user.php: http://pastebin.com/txunsgm1
full pledge.php: http://pastebin.com/mta6aivm
i knew derpy error. had
* @orm\manytomany(targetentity="foo\userbundle\entity\user", inversedby="pledgedon")
and
* @orm\manytomany(targetentity="foo\barbundle\entity\pledge", inversedby="pledgedusers")
one of them had mappedby
instead of inversedby
. changing second 1
* @orm\manytomany(targetentity="foo\barbundle\entity\pledge", mappedby="pledgedusers")
fixed problem.
Comments
Post a Comment