简体   繁体   English

Sonata Admin:显示动作而不是编辑的一对多路线

[英]Sonata Admin: One-to-many route to show action instead of edit

My problem is simple, but I can't find an answer anywhere in the docs or the code...我的问题很简单,但我在文档或代码中的任何地方都找不到答案......

When configuring show fields for a one-to-many relation, the records correctly appear in a list on the show page.为一对多关系配置显示字段时,记录会正确显示在显示页面的列表中。 They incorrectly link to the records edit action instead of the show action.它们错误地链接到记录编辑操作而不是显示操作。 Is there an easy way to change this.有没有简单的方法来改变这一点。 Intuitively, I would guess it would look something like this:直觉上,我猜它看起来像这样:

$showMapper
  ->add('items', null, [
    'action' => 'show',
  ])
;

This obviously didn't work.这显然是行不通的。

Also if anyone can point me to documentation where it lists what key value pairs are possible for $fieldDescroptionOptions that would be very helpful.另外,如果有人可以指出我的文档,其中列出了$fieldDescroptionOptions可能的键值对,这将非常有帮助。

Not sure if there is documentation for that part but to change the route the option should be something like this:不确定是否有该部分的文档,但要更改路线,选项应该是这样的:

->add('items', null, ['route' => ['name' => 'show']])

Looked it up in the template:在模板中查找:

admin-bundle\src\Resources\views\CRUD\Association\list_one_to_many.html.twig

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM