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

Bug TOTAL_FORMS and delete option #173

Closed stefgmz closed 4 years ago

stefgmz commented 4 years ago

Current behaivor: After adding forms, deleting forms works until totalForms.val() > minForms.val(). showDeleteLinks() returns the correct value for when the delete links should appear. But if one of the INITIAL_FORMS is deleted, then the form is not deleted but hided, and the TOTAL_FORMS value is not updated. For example, if you set in Django min_num=1 and extra=0, then click 'add another', then delete the first of the two forms by clicking 'remove'. You end up with one row for input, but the 'remove' link is still there and allows to remove the last form too. So technically, you can remove all forms.

Expected behaivor: After reaching min_num, remove link should disappear.

anryangelov commented 2 years ago

But this introduce another bug. Now if you try to remove the last form it would not be removed. Since originally form-TOTAL_FORMS counter is not reduced when for form delete is "on".