【问题标题】:Correctly show mapping association using inheritance使用继承正确显示映射关联
【发布时间】:2020-01-06 18:03:14
【问题描述】:

我正在使用教义Class Table Inheritance 处理实体继承。

我有一个基础实体 BaseEntity

然后我有 FirstEntitySecondEntity 扩展了 BaseEntity

另一方面,我有一个 StandardEntity,它有一个名为 baseEntitiesOneToMany BaseEntity 映射关联。

StandardEntity 的视图页面中,还应显示与此相关的 BaseEntity 列表。

但我遇到了一些麻烦。

第一个错误

An exception has been thrown during the rendering of a template ("Warning: nl2br() expects parameter 1 to be string, object given").

第一种解决方案:我将属性的类型强制为关联

- { property: baseEntities, type: association }

我遇到了第二个错误

An exception has been thrown during the rendering of a template ("Notice: Undefined index: targetEntity").

但如果我将类型设置为 array,我会得到正确的项目列表,但只有简单的文本。我想要链接到相关实体的链接 - FirstEntitySecondEntity - 查看页面。

- { property: baseEntities, type: array }

【问题讨论】:

    标签: doctrine-orm symfony4 symfony2-easyadmin easyadmin


    【解决方案1】:

    需要在有问题的实体的类中添加type“association”和type_options才能有链接,例如这里我使用我的class Tag

     { property: 'tags', type: 'association', type_options: 'App\Entity\Tag' }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-10-31
      • 1970-01-01
      • 1970-01-01
      • 2017-12-07
      • 2011-11-22
      • 2010-11-25
      • 1970-01-01
      相关资源
      最近更新 更多