[英]Sonata Admin Change Edit link by Show link
I'm using SonataAdminBundle and I'm triying to change the edit link of and entity by the show link. 我正在使用SonataAdminBundle,我正在试图通过show链接更改和实体的编辑链接。
I want to do this because I need the entity couldn't be modified but I want you can show the entity by clicking in the Identifier field of the list page. 我想这样做是因为我需要实体无法修改但我希望您可以通过单击列表页面的标识符字段来显示实体。
I need to show the entity by clicking in the Identifier, and not using the show action buttom. 我需要通过单击标识符来显示实体,而不是使用show action buttom。
So I tried in the ClassAdmin: 所以我尝试了ClassAdmin:
protected function configureRoutes(RouteCollection $collection){
$collection->add('edit', $this->getRouterIdParameter().'/show');
}
Despite the url is generated with the show correctly, the Identifier in the list page redirect to the edit page. 尽管url是在节目中正确生成的,但列表页面中的标识符会重定向到编辑页面。 Really, wathever I change in the edit link doesn't take efect and always redirect to the edit page.
实际上,我在编辑链接中进行了更改并不会产生效果并始终重定向到编辑页面。
Thansk a lot! Thansk很多!
You can give the default action like this (in your admin classes): 您可以像这样给出默认操作(在您的管理类中):
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('id', null, ['route' => ['name' => 'show']])
;
}
Finally, it works by: 最后,它的工作原理是:
protected function configureRoutes(RouteCollection $collection){
$collection->remove('edit');
$collection->add('edit', $this->getRouterIdParameter().'/show');
}
I don't know why I have to remove the edit link first... but it works. 我不知道为什么我必须首先删除编辑链接...但它的工作原理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.