jrief / django-formset

The missing widgets and form manipulation library for Django
https://django-formset.fly.dev/
MIT License
317 stars 30 forks source link

bug in uploadedfileinput widget #96

Closed ozgur-as closed 10 months ago

ozgur-as commented 10 months ago

hi there,

in my own project, i am using a collection to be able to add multiple images in a single form. i have come across a bug, so i wanted to reproduce it in the testapp with a simple gallery example. you can access the branch from: https://github.com/ozgur-as/django-formset/tree/reproduce-file-input-widget-bug

the example works as it should if you are just uploading for the first time/deleting/updating and doing a form submit after each action, but if you do the following actions without submitting the form the bug occurs:

browser console throws the following javascript error:

django-formset.js:25 Uncaught Error: More than one form has id="id_images.2.image"
    at dr.assignFieldsToForms (django-formset.js:25:27803)
    at HTMLButtonElement.appendFormCollectionSibling (django-formset.js:25:24025)

the widget's progress bar and choose file button stays unresponsive and submitted form would not save properly because of the mixed id's i suppose.

i hope it's a clear description of the steps :)

thanks in advance!

jrief commented 10 months ago

so which view/URL are you using then?

Just saw it myself: /bootstrap/gallerycollection

ozgur-as commented 10 months ago

i was using /default/gallerycollection but the bootstrap one produces the same bug as well.

jrief commented 10 months ago

I can confirm this bug and believe to have found a solution.

Please checkout my branch at https://github.com/jrief/django-formset/tree/reproduce-file-input-widget-bug remember to recompile.

Thanks for reporting and please tell me if this works.

ozgur-as commented 10 months ago

yup, it looks fine to me :) thanks!

jrief commented 10 months ago

Released in version 1.3.3