Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sonataadminbundle: Multiple admin section for same entity

Tags:

I have entity class Page with column type=integer. When I do:

   <service id="sonata.admin.pages" class="Main\ProgramBundle\Admin\PageAdmin">       <tag name="sonata.admin" manager_type="orm" group="dashboard" label="Pages"/>       <argument />       <argument>Main\ProgramBundle\Entity\Page</argument>       <argument>SonataAdminBundle:CRUD</argument>   </service>      <service id="sonata.admin.groups" class="Main\ProgramBundle\Admin\GroupAdmin">       <tag name="sonata.admin" manager_type="orm" group="stories" label="Groups"/>       <argument />       <argument>Main\ProgramBundle\Entity\Page</argument>       <argument>SonataAdminBundle:CRUD</argument>   </service> 

In short, both sections work on same entity except that each have different queries and forms.

But what happens is that sonata always executes Admin/GroupAdmin, even if I select PageAdmin. How to do this?

like image 323
Zeljko Avatar asked Oct 10 '12 20:10

Zeljko


1 Answers

I don't have enough reputation to add a comment to the previous answer, but it is missing the following information:

You also need to define a unique $baseRouteName value in addition to $baseRoutePattern in your admin classes:

protected $baseRouteName = 'admin_vendor_bundlename_adminclassname';  protected $baseRoutePattern = 'unique-route-pattern'; 

You only need to do this to one class, but consider doing it in both to keep it clear what's going on.

like image 141
Barry Avatar answered Oct 02 '22 14:10

Barry