Search code examples
phpsymfonysymfony-sonatasonata-admin

Sonata Admin Dashboard: configure actions per entity


I'm using the SonataAdminBundle as base for an administration interface for a Symfony2 (v2.0.x) powered website.

Entities which are added to the dashboard in SonataAdmin have the following actions by default:

  • add
  • list

This works fine for most entities, however the website has a few entities for which data is not added via the admin interface - i.e. they are entered from the public facing website. Administrators only need to view them ("list" action in dashboard), edit them or delete them. Administrators should not be able to add data to these entities.

Is there a way to configure which actions are displayed next to individual entities in SonataAdmin dashboard?


Solution

  • In your EntityAdmin class add following

    public function configureRoutes(RouteCollection $collection)
    {
      $collection->remove('create');
    }