-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FormArray insert a FormGroup to an specific index does not work properly #66
Comments
Hi @gucci-quoci, Thanks for using Reactive Forms and for the issue. If I understand well, the code above actually execute well without problems. Could you please write and example about the code that actually doesn't work, so I can better understand the issue. Thanks. |
Hey I added an example. The code above works only for the add button. If I use the copy button it does not work properly. |
Hey @joanpablo this is the code, which does not work properly.
|
Hi @gucci-quoci, Sorry for the late answer. The issue there is because of how Flutter handles elements in a list in the UI. If you put a key to all your ReactiveTextField the issue will be resolved. final group = array.controls[i] as FormGroup;
ReactiveTextField(
key: ObjectKey(group),
formControlName: 'name',
), |
Hi @joanpablo, |
Hey I'm trying to copy a FormGroup in a FormArray if I press a button. Adding a new FormGroup to the array like in the code below works. But if I make a copy by using the insert method with a given index it doesn't work properly. Editing the original FormGroup, will change the value of the copy as well and vice versa. I want to copy a FormGroup in a FormArray and edit only one of them and not both. In this example I copy the first item and put it to index 0.
Example:
[0] - A
[0] - A (new)
[1] - A (old)
[0] - AB
[1] - AB <-- Should not change to AB
The text was updated successfully, but these errors were encountered: