我想在列表页面中的“btn action-new”附近添加自定义操作。 我尝试:
entities:
Pratiquant:
class: AppBundle/Entity/Pratiquant
actions:
- {name: 'fichePresence', type: 'method', action: 'fichePresence', label: 'fiche de presence' }
我不需要这个:
entities:
Pratiquant:
class: AppBundle/Entity/Pratiquant
list:
actions:
- {name: 'fichePresence', type: 'method', action: 'fichePresence', label: 'fiche de presence' }
希望有人理解我!
最佳答案
您的配置是正确的...但它没有达到您想要实现的目标。现在,为 list
View 配置的所有操作都被视为针对列表中显示的项目的操作。没有内置方法可以为 list
View 定义“全局操作”。
无论如何,您都可以通过覆盖 list
模板的一小部分来完成您想要的操作。为此,请创建以下 Twig 模板(将其存储在确切的位置非常重要):
{# 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 %}
这将执行自定义 AdminController
的 fichePresenceAction()
方法。
关于Symfony Easyadmin - 如何在 "btn action-new"附近添加自定义操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34655996/