0
votes

Im working with entities inheritances using doctrine Class Table Inheritance.

I have a base entity BaseEntity.

Then I have FirstEntity and SecondEntity that extends the BaseEntity.

In other hands, I have a StandardEntity that have a mapping association of OneToMany BaseEntity named baseEntities.

In the view page of an StandardEntity, it should also show the list of BaseEntity that is related to this one.

But I've got some trouble with that.

First error:

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

First solution: I forced the type of the property to association.

- { property: baseEntities, type: association }

I've got a second error:

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

But if I set the type to array, I get the correct item list but there is just simple text. I would like to have links that link to the related entity - FirstEntity or SecondEntity - view page.

- { property: baseEntities, type: array }
1

1 Answers

1
votes

It is necessary to add the type "association" and type_options the class of the entity in question to also have the links, for example, here I use my class Tag

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