newforms
newforms copied to clipboard
Allow removal of forms in a formset that are not "extra"
Getting an error of
Can't remove a form when there are no extra forms
when I try to remove a form in a formset that is populated with initial data.
What is the reason for disallowing removal of those forms?
+1
I don't know if you guys still care, I had the same problem so I just hijacked the removeForm method in FormSet.js in the node module
my formSet is called airlineFormSet
deleteItemAirline(index) { this.state.airlineFormSet.extra--; if (this.state.airlineFormSet._forms !== null) { this.state.airlineFormSet._forms.splice(index, 1) } if (this.state.airlineFormSet._errors !== null) { this.state.airlineFormSet._errors.splice(index, 1) } this.state.airlineFormSet._stateChanged(); }