簡體   English   中英

Sonata管理員更改編輯鏈接顯示鏈接

[英]Sonata Admin Change Edit link by Show link

我正在使用SonataAdminBundle,我正在試圖通過show鏈接更改和實體的編輯鏈接。

我想這樣做是因為我需要實體無法修改但我希望您可以通過單擊列表頁面的標識符字段來顯示實體。

我需要通過單擊標識符來顯示實體,而不是使用show action buttom。

所以我嘗試了ClassAdmin:

protected function configureRoutes(RouteCollection $collection){

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

}

盡管url是在節目中正確生成的,但列表頁面中的標識符會重定向到編輯頁面。 實際上,我在編輯鏈接中進行了更改並不會產生效果並始終重定向到編輯頁面。

Thansk很多!

您可以像這樣給出默認操作(在您的管理類中):

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

最后,它的工作原理是:

protected function configureRoutes(RouteCollection $collection){

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

}

我不知道為什么我必須首先刪除編輯鏈接...但它的工作原理。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM