[英]How to remove the actions in a Sonata admin class?
I am working with a Symfony 2.7 app that uses the Sonata admin bundle. 我正在使用使用Sonata管理员捆绑包的Symfony 2.7应用程序。
In an admin class I've built, the following code is present inside the configureListFields
method: 在我建立的一个管理类中,
configureListFields
方法中包含以下代码:
->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 在管理类中添加功能configureRoutes
protected function configureRoutes(RouteCollection $collection)
{
$collection->remove('edit')
// or if you want to remove everything except some routes
$collection->clearExcept(array('list', 'show'));
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.