I am working with a Symfony 2.7 app that uses the Sonata admin bundle.
In an admin class I've built, the following code is present inside the configureListFields
method:
->add('_action', 'actions', [
'actions' => [
'show' => ['sort'=>''],
'edit' => ['sort'=>''],
'delete' => ['sort'=>''],
]
])
But I don't want all those actions to be present. So I make it look like this instead:
->add('_action', 'actions', [
'actions' => [
'edit' => ['sort'=>''],
]
])
... and I find that, surprisingly, nothing changes in the list view. All three actions are still present. I have also tried removing the "actions" key entirely. Neither approach seems to work.
What am I doing wrong here? How do I remove actions that I don't want?
Add a function configureRoutes in your admin class
protected function configureRoutes(RouteCollection $collection)
{
$collection->remove('edit')
// or if you want to remove everything except some routes
$collection->clearExcept(array('list', 'show'));
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.