Sonata Admin: How to remove "Add New" button from dashboard only? Sonata Admin: How to remove "Add New" button from dashboard only? symfony symfony

Sonata Admin: How to remove "Add New" button from dashboard only?


In your admin class :

use Sonata\AdminBundle\Route\RouteCollection;protected function configureRoutes(RouteCollection $collection){    $collection->remove('create');}

You can also remove Delete, Show etc ...

Check : https://sonata-project.org/bundles/admin/master/doc/reference/routing.html#removing-a-single-route


Try this in the admin class:

public function getDashboardActions() {    $actions = parent::getDashboardActions();    unset($actions['create']);    return $actions;}


In the following you can see a list of options to hide Sonatadmin functions:

protected function configureRoutes(RouteCollection $collection){    $collection->remove('create');    $collection->remove('edit');    $collection->remove('delete');    $collection->remove('show');    $collection->remove('export');}