【问题标题】:Creating automatic crud grid and actions with Sylius (Symfony bundle)使用 Sylius(Symfony 捆绑包)创建自动 crud 网格和操作
【发布时间】:2017-01-06 16:48:22
【问题描述】:

我尝试使用 Sylius Grid 系统来简化我的文章管理。 所以,我关注了Sylius doc,我看到了显示我的文章的网格。然后我添加了操作按钮,但是当我想使用它们时,出现错误(仅用于编辑和创建。删除效果很好):Class "form" is not configured for resource "blog.article".

我知道它找不到任何 FormClass 来呈现我的文章,但文档中没有此信息,我想我在文档上看到(我不记得是哪个)表单是自动呈现的根据实体。

这是我的代码:

资源声明:

sylius_resource:
    resources:
        blog.article:
            driver: doctrine/orm
            classes:
                model: BlogBundle\Entity\Article

网格配置:

sylius_grid:
    grids:
        blog_admin_article:
            driver:
                name: doctrine/orm
                options:
                    class: BlogBundle\Entity\Article
            sorting:
                date: asc
            fields:
                titre:
                    type: string
                    label: sylius.ui.title
                    sortable: ~
                date:
                    type: datetime
                    label: sylius.ui.date
                    sortable: ~
                resume:
                    type: string
                    label: sylius.ui.resume
                    sortable: ~
            filters:
                search:
                    type: string
                    label: sylius.ui.search
                    options:
                        fields: [titre, resume ]
            actions:
                main:
                    create:
                        type: create
                        label: sylius.ui.create
                item:
                    update:
                        type: update
                    delete:
                        type: delete
                    show:
                        type: show

路线:

blog_admin_article:
    resource: |
        alias: blog.article
        section: admin
        templates: SyliusAdminBundle:Crud
        except: ['show']
        redirect: update
        grid: blog_admin_article
        vars:
            all:
                subheader: blog.ui.articles.subtitle 
            index:
                icon: 'newspaper icon'
    type: sylius.resource

有谁知道问题出在哪里?

感谢您的帮助!

【问题讨论】:

    标签: grid symfony crud sylius


    【解决方案1】:

    由于在 beta1 中禁用了表单的自动生成,有两种方法可以解决您的问题:

    1. 创建并声明您自己的表单类型like here in the docs (ArticleType)。

    2. 使用 Sylius 的 dev-master 分支而不是 beta1,自动生成又回来了。

    【讨论】:

    • 感谢 CoderMaggie,我会试试这个。我怎么知道有更新的版本?我在作曲家文档上看到有一个“过时”的选项,但它不适用于我的作曲家...
    • 将“sylius/sylius”:“^1.0@beta”更改为“sylius/sylius”:“dev-master”,当我想在 url 显示文章时出错“/以前工作的文章”:"Unable to generate a URL for the named route "blog_admin_article_show" as such route does not exist."
    • 好的,show: type: show 是我的网格配置中的问题。
    • 很高兴您已设法修复它。 :) 在发布时,您必须关注 Sylius(博客、推特、github、slack,随心所欲)。
    猜你喜欢
    • 1970-01-01
    • 2018-05-15
    • 1970-01-01
    • 1970-01-01
    • 2018-12-31
    • 1970-01-01
    • 1970-01-01
    • 2017-04-26
    • 2013-09-24
    相关资源
    最近更新 更多