I'm using SonataAdminBundle and I'm triying to change the edit link of and entity by the show link.
I want to do this because I need the entity couldn't be modified but I want you can show the entity by clicking in the Identifier field of the list page.
I need to show the entity by clicking in the Identifier, and not using the show action buttom.
So I tried in the ClassAdmin:
protected function configureRoutes(RouteCollection $collection){
$collection->add('edit', $this->getRouterIdParameter().'/show');
}
Despite the url is generated with the show correctly, the Identifier in the list page redirect to the edit page. Really, wathever I change in the edit link doesn't take efect and always redirect to the edit page.
Thansk a lot!
You can give the default action like this (in your admin classes):
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('id', null, ['route' => ['name' => 'show']])
;
}
Finally, it works by:
protected function configureRoutes(RouteCollection $collection){
$collection->remove('edit');
$collection->add('edit', $this->getRouterIdParameter().'/show');
}
I don't know why I have to remove the edit link first... but it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With