Symfony 5 referencing a field within a referenced table

The question hard to formulate in just one sentence when I don’t have the exact terms ready for use, but I’m basically working on a Symfony 5 project that involves a MySQL database. I use Twig to allow for communication between my PHP controllers and my HTML interface. Until now, I’ve been doing just fine using simple references to entity fields in Twig, such as:

myEntity.someField

To get the value I needed. However, I currently need to reference a "nested" field like so :

myEntity1.myEntity2Field.someField

The "nesting" making a world of a difference between the two. I am now getting an error when trying to do this, probably because my database is not organized correctly yet, from what I understand. Hopefully you could understand my difficulty. So, how can I tweak my database to allow this sort of double-referencing to take place?

Note: myEntity2Field refers to the name of a field from Entity2 that should serve as a reference to the entire Entity2 table, from which someField can then be extracted.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *