sonata-project / SonataDoctrineORMAdminBundle

Integrate Doctrine ORM into the SonataAdminBundle
https://docs.sonata-project.org/projects/SonataDoctrineORMAdminBundle
MIT License
445 stars 345 forks source link

Have an option to set the default route name of associations link #1160

Closed soullivaneuh closed 3 years ago

soullivaneuh commented 6 years ago

Concerning those templates: https://github.com/sonata-project/SonataAdminBundle/tree/1a46603f9d4cf44edab5b73d49751f1848630fb0/src/Resources/views/CRUD/Association

And maybe the old ones from ORM/ODM bundles.

The default route name for association links is edit.

First, that does not really make sens to show the entity form when you click on a link from the list, but why not.

Second, there is no way to have the route set to show as default, except filling the option on each field of each admin class.

It would be great to have an option for that, maybe on configuration.

Note: I was sure to already open an issue like this, but I can't retrieve it.

stale[bot] commented 4 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

VincentLanglet commented 4 years ago

You can implement your own ModelManager and overriding the function

    public function getNewFieldDescriptionInstance($class, $name, array $options = [])
    {
        if (!isset($options['route']['name'])) {
            $options['route']['name'] = 'show';
        }

        return parent::getNewFieldDescriptionInstance($class, $name, $options);
    }

But I agree that there is no sens to link to the edit page. IMO this should link to the show one.

Maybe we could change this behaviour for the 4.0. @sonata-project/contributors ?

VincentLanglet commented 3 years ago

show will be the default behavior in 4.0. An option could be interesting but is not necessary anymore.