This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Sonata parentAssociationMapping not working

Discuss Symfony 2 bundles here

Sonata parentAssociationMapping not working

by belinea » Thu Oct 30, 2014 11:13 pm

I can't figure out how on earth is the child admin being setup so it's using a url relative to parent, eg, /admin/post/1/comment/list. Docs and people's examples document the use of
Code: Select all
 protected $parentAssociationMapping = 'comment';

which in this case would be specified in Admin class, but first thing that happens to me is that system throws an error

Code: Select all
 FileLoaderLoadException: Cannot import resource "Symfony/app/config/." from "Symfony/app/config/sonata_routing.yml". (Cannot automatically determine base route name, please define a default `baseRouteName` value for the admin class `MyBundle\Admin\CommentAdmin`)

And I have no idea what baseRoutePattern should be to include the /post/ID/ (or is this even the correct way to do this). I might add that I'm using doctrine and I already added the addChild service to xml config as described in the sonata docs

Can you please help to sort this out? I was able to display child list with a parent id param but thru the use of configureSideMenu

Code: Select all
    'Content Revisions',
    array('uri' => $admin->generateUrl('sonata.admin.comment.list', array('id' => $id)))

but because this only appends ?id=ID at the end of the url, it gets broken when using filters that don't add that id to the get string

Help please?!
Junior Member
Posts: 1
Joined: Thu Oct 30, 2014 11:11 pm