symfony 2 SonataAdminBundle 覆盖模板 [英] symfony 2 sonataAdminBundle override template
问题描述
我们如何覆盖单个 Admin 类的奏鸣曲包布局就像我创建了 3 个管理类 userAdmin、productAdmin、ticketAdmin现在我想覆盖 ticketAdmin 编辑操作和编辑模板并在那里添加一些额外的代码.
how can we override sonata bundle layout for a single Admin class like i have created 3 Admin Class userAdmin, productAdmin, ticketAdmin now i want to override ticketAdmin edit action and edit template and add some extra code there.
推荐答案
如果你不想创建额外的控制器,你可以使用文档中提到的这个方法:
If you don't want to create an extra controller you can use this method mentioned in the docs:
管理员文档 - 参考 - 模板(主) - 20.6.配置模板
services:
sonata.admin.post:
class: Acme\DemoBundle\Admin\PostAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "Content", label: "Post" }
arguments:
- ~
- Acme\DemoBundle\Entity\Post
- ~
calls:
- [ setTemplate, [edit, AcmeDemoBundle:PostAdmin:edit.html.twig]]
并将您的模板放在 Resources/views/PostAdmin/edit.html.twig 中.只需从 SonataAdmin Bundle 复制原始模板并开始覆盖.
And put your template in Resources/views/PostAdmin/edit.html.twig. Just copy the original template from the SonataAdmin Bundle and start overriding.
博客地址:覆盖 SonataAdminBundle 中的列表视图树枝模板 – webDEVILopers 博客
这篇关于symfony 2 SonataAdminBundle 覆盖模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!