EasyAdminBundle
EasyAdminBundle copied to clipboard
add possibility to use route parameters on crud actions
Short description of what this feature will allow to do: This feature will allow to pass query parameters to crud actions. It can be useful to be able to reuse the same action with little variations based on parameters.
Example of how to use this feature
Usage will be similar to linkToRoute, passing query parameters as second method param.
$viewInvoice = Action::new('viewInvoice', 'Invoice', 'fa fa-file-invoice')
->linkToCrudAction('renderInvoice', ['type' => 'pdf']);
See PR #5144
Hello,
You can do it this way:
// inject EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator in your CrudController
$url = $this
->adminUrlGenerator
->unsetAll()
->setController(self::class)
->setAction('renderInvoice')
->set('type', 'pdf')
->generateUrl();
$viewInvoice = Action::new('viewInvoice', 'Invoice', 'fa fa-file-invoice')
->linkToUrl($url);
Regards
Thx @fabienlem I did not thought about doing it this way :) Definitely going to do this for now.
Still I think it could make things more understandable if we could add parameters when using linkToCrud. Oterwise it sounds a bit like a trick.