I customized templates of action buttons (show, edit and delete) and currently am calling them from within Admin class.
->add('_action', 'actions', array(
'actions' => array(
'show' => array('template' => 'IndexBundle:Admin:action/show.html.twig'),
'edit' => array('template' => 'IndexBundle:Admin:action/edit.html.twig'),
'delete' => array('template' => 'IndexBundle:Admin:action/delete.html.twig')
)
));
But instead of defining templates in each Admin I would like that these templates would rewrite default ones in config file. Unfortunately, documentation does not mention rewriting default action template globally. Is there a way?
sonata_admin:
templates:
...
You can rewrite any part of any bundle, if define new files in 'app' directory.
For your sample, if u just want to rewrite default button templates, u can do this:
{# app/Resources/SonataAdminBundle/views/CRUD/list__action_edit.html.twig #}
{% if admin.isGranted('EDIT', object) and admin.hasRoute('edit') %}
<a href="{{ admin.generateObjectUrl('edit', object) }}" class="btn btn-sm btn-default edit_link" title="{{ 'action_edit'|trans({}, 'SonataAdminBundle') }}">
{# icon was here #}
{{ 'action_edit'|trans({}, 'SonataAdminBundle') }}
</a>
{% endif %}
Use:
Other templates u can found in /vendor/sonata-project/admin-bundle/Resources/views/CRUD/ directory
PS. do not forget to clear cache.