I would like to add a custom action near " btn action-new" in list page. I try:
entities:
Pratiquant:
class: AppBundle/Entity/Pratiquant
actions:
- {name: 'fichePresence', type: 'method', action: 'fichePresence', label: 'fiche de presence' }
I don't need this:
entities:
Pratiquant:
class: AppBundle/Entity/Pratiquant
list:
actions:
- {name: 'fichePresence', type: 'method', action: 'fichePresence', label: 'fiche de presence' }
Hope someone understand me!
Your configuration is correct ... but it doesn't do what you want to achieve. Right now, all the actions configured for the list
view are considered actions for the items displayed in the listing. There is no built-in way to define "global actions" for list
view.
In any case, you can do what you want by overriding a small fragment of the list
template. To do so, create the following Twig template (it's very important to store it in that exact location):
{# app/Resources/views/easy_admin/Pratiquant/list.html.twig #}
{% extends '@EasyAdmin/default/list.html.twig' %}
{% block view_actions %}
{{ parent() }}
<a href="{{ path('easyadmin', { view: 'fichePresence' }) }}">Fiche de presence</a>
{% endblock %}
This will execute the fichePresenceAction()
method of your custom AdminController
.