newforms icon indicating copy to clipboard operation
newforms copied to clipboard

Allow removal of forms in a formset that are not "extra"

Open coreylight opened this issue 9 years ago • 2 comments

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?

coreylight avatar Aug 06 '15 22:08 coreylight

+1

adamziel avatar Oct 07 '15 00:10 adamziel

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(); }

hestacio avatar Jun 08 '17 19:06 hestacio