Sonata管理员更改编辑链接显示链接

Ang*_*gel 4 routes configure hyperlink symfony sonata-admin

我正在使用SonataAdminBundle,我正在试图通过show链接更改和实体的编辑链接.

我想这样做是因为我需要实体无法修改,但我希望您可以通过单击列表页面的标识符字段来显示实体.

我需要通过单击标识符来显示实体,而不是使用show action buttom.

所以我尝试了ClassAdmin:

protected function configureRoutes(RouteCollection $collection){

  $collection->add('edit',  $this->getRouterIdParameter().'/show');

}
Run Code Online (Sandbox Code Playgroud)

尽管url是在节目中正确生成的,但列表页面中的标识符会重定向到编辑页面.实际上,我在编辑链接中进行了更改并不会产生效果并始终重定向到编辑页面.

Thansk很多!

shi*_*ork 22

您可以像这样给出默认操作(在您的管理类中):

protected function configureListFields(ListMapper $listMapper)
{
    $listMapper
        ->addIdentifier('id', null, ['route' => ['name' => 'show']])
    ;
}
Run Code Online (Sandbox Code Playgroud)


Ang*_*gel 7

最后,它的工作原理是:

protected function configureRoutes(RouteCollection $collection){

    $collection->remove('edit');
    $collection->add('edit',  $this->getRouterIdParameter().'/show');

}
Run Code Online (Sandbox Code Playgroud)

我不知道为什么我必须首先删除编辑链接...但它的工作原理.