elo80ka / django-dynamic-formset

A jQuery plugin that allows you dynamically add new forms to a rendered django formset.
677 stars 311 forks source link

Unable to decrement TOTAL_FORMS value below value set for INITIAL_FORMS #155

Open bassasaurus opened 5 years ago

bassasaurus commented 5 years ago

When I update an instance that has multiple formset FKs, I'm unable to add formsets after removing them since the remove link will only work while MAX_FORMS < TOTAL_FORMS > INITIAL_FORMS.

For instance, with this initial data: TOTAL_FORMS = 4 INITIAL_FORMS = 3 MAX_FORMS = 4

If i remove 3 formsets, TOTAL_FORMS only gets decremented by only 1 since INITIAL_FORMS is 3 and I can only add 1 form since MAX_FORMS = 4. So the net result is a formset with a max of 4 with only 1 being able to be editied.

I hope I described the issue well enough. I think TOTAL_FORMS and INITIAL_FORMS need to be decremented simultaneously to allow for the re-addition of formsets after their removal. I'm not a JS guy though. I love this otherwise and really need it to work!

Thanks screen recording 2018-11-20 at 11 17 38 pm

Mindzy commented 4 years ago

If you put multiple formsets in the same view template, formCssClass is required.