Search code examples
symfonysonata-adminsonatasymfony-sonatasonata-user-bundle

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.


Solution

  • 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