symfony - SonataDoctrineORMAdminBundle 抛出 array_combine 错误

标签 symfony doctrine-orm sonata-admin symfony-sonata

我有一个多对多关系,它发出警告:

Warning: array_combine(): Both parameters should have an equal number of elements in vendor/sonata-project/doctrine-orm-admin-bundle/Sonata/DoctrineORMAdminBundle/Model/ModelManager.php line 179

相关管理类工作正常,直到使用 Composer 将 SonataDoctrineORMAdminBundle 更新到版本 2.2.4。

我认为问题可能出在我的模型上,但不确定是什么。

bundle\Entity\EntityOne:
    type: entity
    table: entityOne

    fields:
        id:
            type: integer
            id: true
            generator:
                strategy: AUTO
        title:
            type: string
            length: '100'

    oneToMany:
        entityRel:
            targetEntity: EntityRel
            mappedBy: entityOne
            cascade: ["persist", "remove"]

    lifecycleCallbacks: {  }



bundle\Entity\EntityRel:
    type: entity
    table: entityRel
    id:
        entityOne:
            associationKey: true
        entityTwo:
            associationKey: true
    fields:
        amount:
            type: decimal
    oneToOne:
        entityOne:
            targetEntity: EntityOne
        entityTwo:
            targetEntity: EntityTwo
    lifecycleCallbacks: {  }



bundle\Entity\EntityTwo:
    type: entity
    table: entityTwo
    fields:
        id:
            type: integer
            id: true
            generator:
                strategy: AUTO
        name:
            type: string
            length: '100'

    oneToMany:
        entityRel:
            targetEntity: entityRel
            mappedBy: entityTwo
            cascade: ["persist", "remove"]

    lifecycleCallbacks: {  }

这个想法是 EntityRel 通过金额字段连接 EntityOne 和 EntityTwo。两个表之间的每个连接都必须是唯一的,从而强制键是复合的。

有什么想法吗?

最佳答案

您似乎错过了 EntityTwo 的表格:

bundle\Entity\EntityTwo:
type: entity
table: entityTwo

关于symfony - SonataDoctrineORMAdminBundle 抛出 array_combine 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19700240/

相关文章:

php - Doctrine 将 bigint 作为字符串获取 - 如何防止这种情况

php - 将可嵌入字段设置为父实体映射的主键 - Doctrine2

php - Symfony 4 - 找不到所有迁移版本

php - 如何更改 SonataAdmin 中的 "sonata project"链接?

php - DQL 允许空连接吗?

symfony - 删除 Symfony 缓存文件夹 - 用于无状态水平缩放

php - Symfony2 使用 Doctrine UNIQUE INDEX 和 ORDER BY 持久化表单集合?

php - 快速实体主义水化器

php - Sonata 管理员覆盖服务配置

php - 如何在 Sonata Admin Bundle configureFormFields 中使用现有的 Symfony FormType?