2

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!

4

2 回答 2

6

您的配置是正确的......但它并没有达到您想要的效果。现在,为list视图配置的所有操作都被视为列表中显示的项目的操作。list没有为视图定义“全局操作”的内置方法。

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 %}

这将执行fichePresenceAction()您的自定义方法AdminController

于 2016-01-07T13:57:09.240 回答
1

使用 EasyAdmin 3:

public function configureActions(Actions $actions): Actions
{
    $fichePresence = Action::new('fichePresence', 'fiche de presence', 'fa fa-download')
        ->linkToCrudAction('fichePresenceAction')
        ->createAsGlobalAction();

    return $actions
        ->add(Crud::PAGE_INDEX, Action::DETAIL)
        ->add(Crud::PAGE_INDEX, $fichePresence);
}

查看文档

于 2022-02-16T10:53:38.527 回答