You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an entity "Main" which has a OneToMany relation named "children" to the entity "Child".
class Main
{
#[ORM\OneToMany(targetEntity: Child::class, mappedBy: 'main')]
private Collection $children;
Inside the "Child" there is a ManyToOne relation named "other" to another entity named "Related".
class Child
{
#[ORM\ManyToOne]
private ?Related $other = null;
When a new child is created I want to set a default value for the relation "other".
I can't do it in the constructor of the entity because I would need the entitymanager for that.
I can't use a factory class, because I want to use this in a livecomponent with a livecollection
and there the creation of the objects is done internally.
So I do it via the data option in the formtype for child:
but does not work in a live component with a live collection.
Since the live collection does all the work internally when creating/adding a new child,
I don't know how or where I can initialize the child.other relation property!
Is this the expected behaviour? What am I doing wrong? Can someone help?
I have an entity "Main" which has a OneToMany relation named "children" to the entity "Child".
Inside the "Child" there is a ManyToOne relation named "other" to another entity named "Related".
When a new child is created I want to set a default value for the relation "other".
I can't do it in the constructor of the entity because I would need the entitymanager for that.
I can't use a factory class, because I want to use this in a livecomponent with a livecollection
and there the creation of the objects is done internally.
So I do it via the data option in the formtype for child:
This does work in a normal form
but does not work in a live component with a live collection.
Since the live collection does all the work internally when creating/adding a new child,
I don't know how or where I can initialize the child.other relation property!
Is this the expected behaviour? What am I doing wrong? Can someone help?
Reproducer:
live-collection-reproducer-zip.zip
The text was updated successfully, but these errors were encountered: