5

我正在使用 SonataAdminBundle,我正在尝试通过显示链接更改编辑链接和实体。

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

我需要通过单击标识符来显示实体,而不是使用显示操作按钮。

所以我在 ClassAdmin 中尝试了:

protected function configureRoutes(RouteCollection $collection){

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

}

尽管显示正确生成了 url,但列表页面中的标识符重定向到编辑页面。真的,无论我在编辑链接中进行的更改都不会生效,并且总是重定向到编辑页面。

非常感谢!

4

2 回答 2

24

您可以提供这样的默认操作(在您的管理类中):

protected function configureListFields(ListMapper $listMapper)
{
    $listMapper
        ->addIdentifier('id', null, ['route' => ['name' => 'show']])
    ;
}
于 2013-05-28T12:20:46.080 回答
8

最后,它的工作原理是:

protected function configureRoutes(RouteCollection $collection){

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

}

我不知道为什么我必须先删除编辑链接......但它有效。

于 2013-06-04T08:15:42.347 回答