On this page, I found a way to add a route for my custom action.
protected function configureRoutes(RouteCollection $collection) { $collection->add('ispremium', $this->getRouterIdParameter().'/ispremium'); }
After that, I add a custom action to my Admin class:
protected function configureListFields(ListMapper $listMapper) { $listMapper ->addIdentifier('id') ->add('code', null, array('label' => 'Code')) ->add('_action', 'actions', array( 'actions' => array( 'ispremium' => array( 'template' => 'AppMyBundleBundle:Admin:ispremium.html.twig' ) ) )) ; }
It generated url like this:
/app_dev.php/admin/mobispot/discodes/discode/300876/ispremium
My template for this link:
<a href="{{ admin.generateObjectUrl('ispremium', object) }}">Link</a>
I do not know how to solve these problems:
How to define a user controller for this route? Now I have an error:
The method "Sonata \ AdminBundle \ Controller \ CRUDController :: ispremiumAction" does not exist.
Is it possible to change the generated url using the generateUrl method?
php symfony sonata-admin symfony-sonata
Sergey Zherevchuk
source share