bietkul / react-reactive-form

Angular like reactive forms in React.
MIT License
309 stars 32 forks source link

To remove multiple controls from dynamic FormArray not working with removeAt #63

Open MartinJesu opened 4 years ago

MartinJesu commented 4 years ago

Describe the bug To remove multiple controls from dynamic FormGroup not working with removeAt. My case i want to remove multiple FormControls from FormGroup then need to push new multiple FormControls in the same FormGroup. At that time removeAt will not worked.

If i loop through my FormGroup & try to use removeAt it will execute only one time then break the loop, also i have other logic codes below that also not executable.

I tried like below code,

control.meta.currentForm.controls['dynamicSelector']['controls'].forEach((child, index) => { child.removeAt(index); });

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.