2017-02-27 41 views
0

我已经从自定义资源(简报)创建了一个网格,并且我想在每行上添加一个“发送”按钮,旁边是默认的“编辑”和“删除“ 纽扣。 但我不知道如何定义网格定义自定义操作,我不觉得在Sylius文档的信息...在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 

任何如何做到这一点的想法?

谢谢!

回答

3

我猜想,所有你需要做的就是增加自己的动作模板(的appbundle /资源/视图/表格/动作/ 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" 

检查模板路径,因为我不知道这一点。

+0

就是这样! Tks CoderMaggie :) – wyllyjon

相关问题