Finally, I found a solution by changing the template:
This is my admin class :
protected function configureListFields(ListMapper $listMapper)
{
$listMapper->add('cv', null, array('template' => 'admin/list_field_cv.html.twig'));
}
and this is my custom template :
{% extends admin.getTemplate('base_list_field') %}
{% block field %}
{% if value %}
{% set route_name = field_description.options.route.name %}
{% if not field_description.options.identifier|default(false) and
field_description.hasAssociationAdmin and
field_description.associationadmin.hasRoute(route_name) and
field_description.associationadmin.hasAccess(route_name, value) %}
<div class="btn-group">
<a class="btn btn-default btn-sm btn-block"
href="{{ field_description.associationadmin.generateObjectUrl(route_name, value, field_description.options.route.parameters) }}">
{{ value|render_relation_element(field_description) }} : to media
</a>
<a class="btn btn-info btn-sm btn-block"
href="{{ path('sonata_media_download', {'id': (object.cv.id)}) }}">
{{ value|render_relation_element(field_description) }} : Télécharger
</a>
<a class="btn btn-link btn-sm btn-block"
href="{% path object.cv,'reference' %}">
{{ value|render_relation_element(field_description) }} : Ouvrir
</a>
</div>
{% else %}
{{ value|render_relation_element(field_description) }}
{% endif %}
{% endif %}
{% endblock %}
Hope this helps!
source
share