简体   繁体   中英

Configure custom template for Sonata Admin bundle

I have created a custom template for create action, I tried to configure it as mentioned in the documentation:

article.admin.article:
    class: ArticleBundle\Admin\ArticleAdmin
    arguments: [~, ArticleBundle\Entity\Article, "ArticleBundle:ArticleAdmin"]
    tags:
        - { name: sonata.admin, manager_type: orm, group: admin, label: Article }
    calls:
        - [ setTemplate, [create, "ArticleBundle:ArticleAdmin:ArticleBundle"]]

My new create.html.twig template is in directory: src\\ArticleBundle\\Resources\\views\\ArticleAdmin\\ArticleBundle

When I load create page I still get the default template, not the one I configured.

What can be wrong?

In:

group: admin, label: Article

you are missing double quotes. Should be:

group: "admin", label: "Article"

The call for setTemplate should be:

calls:
    - [ setTemplate, [create, "ArticleBundle:ArticleAdmin:ArticleBundle/create.html.twig"]]

See Sonata Admin templates reference.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM