Issue
I have a person form that has some basic properties and also has a node called relatives
let personFormGroup = this.fb.group({
id: new FormControl(),
gender: new FormControl(),
...
relatives: this.createRelatives(),
});
the problem is that Relatives is an array of RelativePerson which has some unique basic properties and also a Person inside it
let relativeFormGroup = this.fb.group({
id: [null], // Initialize with default values or null
relation_type: [''],
...
Person: this.createPersonControl(),
comments: ['']
});
the problem is I can't duplicate either one cuz that's bad practice and even if I want both of them have lots of properties, so how can I handle such circular relation where I can create a person add relativePeople
Solution
The person form must contain an empty relative array, so when you add a FormGroup for relatives, it will contain persons without relatives, and use patch style in the backend.
Answered By - Mohamed Magdy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.