Symfony 2.3.25, SonataAdminBundle
If i remove the 'delete' route from my admin by
$collection->clearExcept(array('list'));
in configureRoutes I get no 'batch' column in List View, which is what I want.
But I need the 'delete' action.
When I configureRoutes:
$collection->clearExcept(array('list', 'delete'));
I get the 'batch' column back, which I do not want. I do not want any batch actions or batch columns or anything batch.
I do want a 'Delete' button per row in an Actions column, which I get.
How do I suppress the batch column in list view?
You can remove or add batch actions by overriding the batchActions method. You just have to add your own batchActions method in your Admin class.
To remove the delete action you have to do this :
class Admin
{
public function getBatchActions()
{
$actions = parent::getBatchActions();
unset($actions['delete']);
return $actions;
}
}
The documentation of the default SonataAdmin batchActions method : https://github.com/sonata-project/SonataAdminBundle/blob/master/Admin/Admin.php#L1142
Update for year 2016+. Now you can customize batch actions by using:
configureBatchActions
method inside your Admin class.
/**
* Allows you to customize batch actions.
*
* @param array $actions List of actions
*
* @return array
*/
protected function configureBatchActions($actions)
{
return $actions;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With