Problem with setting the default value for a ManyToOne relation but only when used in livecomponent with livecollection #2241
Unanswered
gewait
asked this question in
Questions & Answers
Replies: 1 comment 2 replies
-
Do you already made it work with a standard CollectionType ? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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
Beta Was this translation helpful? Give feedback.
All reactions