【问题标题】:Add custom action in Sylius resource grid在 Sylius 资源网格中添加自定义操作
【发布时间】:2017-02-27 09:15:32
【问题描述】:

我从自定义资源(通讯)创建了一个网格,我想在每一行添加一个“发送”按钮,旁边是默认的“编辑”和“删除”按钮。 但我不知道如何在网格定义中定义自定义操作,也没有在 Sylius 文档中找到相关信息...

这是我的网格定义:

sylius_grid:
    grids:
        admin_newsletter:
            driver:
                name: doctrine/orm
                options:
                    class: NewsletterBundle\Entity\Newsletter
            sorting:
                date: desc
            fields:
                titre:
                    type: string
                    label: sylius.ui.title
                    sortable: ~
                date:
                    type: datetime
                    label: sylius.ui.date
                    sortable: ~
                    options:
                        format: d/m/Y
                envoye:
                    type: twig
                    label: admin.ui.newsletter_envoye
                    sortable: ~
                    options:
                        template: NewsletterBundle:Helper:_sent.html.twig
            filters:
                search:
                    type: string
                    label: sylius.ui.search
                    options:
                        fields: [titre]
            actions:
                main:
                    create:
                        type: create
                item:
                    update:
                        type: update
                    delete:
                        type: delete

                    # This is what I want: 
                    send: 
                        type: send

知道怎么做吗?

谢谢!

【问题讨论】:

    标签: grid symfony sylius


    【解决方案1】:

    我想你需要做的就是添加你自己的动作模板(AppBundle/Resources/views/Grid/Action/send.html.twig),

    然后在app/config/config.yml中配置:

    就像这里定义的默认操作一样:https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/AdminBundle/Resources/config/app/config.yml#L34

    sylius_grid:
        templates:
            action:
                send: "@AppBundle/Grid/Action/send.html.twig"
    

    检查模板路径,因为我不确定。

    【讨论】:

    • 就是这样! Tks CoderMaggie :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多