Sonataadminbundle: Multiple admin section for same entity Sonataadminbundle: Multiple admin section for same entity symfony symfony

Sonataadminbundle: Multiple admin section for same entity


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.


Sonata creates routes automatically based on your entity names. So if you have 2 admin classes, there is a conflict. You have to configure different route pattern.

Add this property to Main\ProgramBundle\Admin\GroupAdmin.php:

protected $baseRouteName = 'page_group';protected $baseRoutePattern = 'page-group';


You certainly found your solution, but another way to do this would be to create a parent class and inherit using inheritance mapping. You are then able to have different repository and sonata admin would not work differently.