symfony - Sonata admin: Display entity grandchildren in sonata_type_collection -
i have following entities:
// appbundle/entity/contacts.php /** * @var collection * * @orm\onetomany(targetentity="nominations", mappedby="contact") **/ private $nominations; // appbundle/entity/nominations.php /** * @var contacts * * @orm\manytoone(targetentity="contacts", inversedby="nominations") **/ private $contact; /** * @var votes * * @orm\onetomany(targetentity="votes", mappedby="nomination") **/ private $votes; // appbundle/entity/votes.php /** * @var nominations * * @orm\manytoone(targetentity="nominations", inversedby="votes") **/ private $nomination;
with following method in contacts entity, loops through nomination records , stuffs them in arraycollection want display in contactsadmin:
// appbundle/entity/contacts.php /** * votes * * @return \doctrine\common\collections\collection */ public function getvotes() { $return = array(); foreach ($this->getnominations() $nom) { $return = array_merge($return, $nom->getvotes()->toarray()); } return new arraycollection($return); } // appbundle/admin/contactsadmin.php $formmapper ->add('votes', 'sonata_type_collection', array( 'required' => false, 'by_reference' => false ), array( 'data_class' => 'appbundle\entity\votes', 'admin_code' => 'app.admin.votes', //this votesadmin service works fine on own 'edit' => 'inline', 'inline' => 'table', ));
but i'm getting error:
the current field
votes
not linked admin. please create 1 target entity : ``
note entity name there blank. i've tried sorts of different combinations of options keep coming same problem: sonata can't figure out entity class , related admin is, though i'm specifying it.
Comments
Post a Comment