在 Sylius 资源网格中添加自定义操作
Add custom action in Sylius resource grid
我已经从自定义资源(时事通讯)创建了一个网格,我想在每一行上添加一个 "send" 按钮,紧挨着默认的 "edit" 和 "delete" 按钮。
但我不知道如何在网格定义中定义自定义操作,而且我在 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
知道怎么做吗?
谢谢!
我想您需要做的就是添加您自己的操作模板 (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"
检查模板路径,因为我不确定。
我已经从自定义资源(时事通讯)创建了一个网格,我想在每一行上添加一个 "send" 按钮,紧挨着默认的 "edit" 和 "delete" 按钮。 但我不知道如何在网格定义中定义自定义操作,而且我在 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
知道怎么做吗?
谢谢!
我想您需要做的就是添加您自己的操作模板 (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"
检查模板路径,因为我不确定。