Sonata Admin: Add custom triggers/actions to list/edit action
To add an action for edit form
Add to your admin class:
protected function configureSideMenu(MenuItemInterface $menu, $action, Admin $childAdmin = null){ if (!$childAdmin && !in_array($action, array('edit'))) { return; } $admin = $this->isChild() ? $this->getParent() : $this; $id = $admin->getRequest()->get('id'); $menu->addChild('My action', array('uri' => 'http://google.com?id=' . $id));}
It will create left side menu for actions like /admin/acme/videos/x/edit/. Having id for current item allows you to build any custom URL.
To add an action for list:In your admin file add
protected function configureListFields(ListMapper $listMapper){ $listMapper ->add('_action', 'actions', array( 'actions' => array( 'act' => array('template' => 'AcmeBundle:Video:my_temp.html.twig'), ) )) ;}
It will add a column with links, then you need to create a template for your column, something like
<a href="{{ admin.generateObjectUrl('delete', object) }}" class="delete_link" title="{% trans from 'SonataAdminBundle' %}action_delete{% endtrans %}"> <img src="{{ asset('bundles/sonataadmin/famfamfam/delete.png') }}" alt="{% trans from 'SonataAdminBundle' %}action_delete{% endtrans %}" /></a>
All examples are taken from link that you provided. Hope it helps