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

Not sending (image) POST data #118

Open goranmaxim opened 8 years ago

goranmaxim commented 8 years ago

I'm using django's form-wizard to create a multi-step form. In the last step, the user can upload (up to) 10 images. Now, I'm not very front-end savvy, so my js/jquery skills are not really that great. Anyway, here's what I have https://dpaste.de/jpbp

I can see the "add another" and "remove" buttons, they work as well (they do create new image upload fields), the problem is, they are copies of the original field.

<div id="form-multi-uploads" class="dynamic-form">
    <input type="hidden" name="1-0-id" id="id_1-0-id">
    <input type="hidden" name="1-0-listing" id="id_1-0-listing">
<div class="form-group animated fadeInDown">
            <label for="id_1-0-image" class="control-label  ">Image</label>
        <div class=" ">
            <input type="file" name="1-0-image" id="id_1-0-image">
        </div>
</div>

So instead of name="1-0-id" id="id_1-0-id" etc. getting updated(++'ed), they end up being a copy of the first (even if I create 5 fields, they all have the same name/id, thus POST-ing only 1 image.)

shafay07 commented 4 years ago

Anyone with a same issue could try using enctype="multipart/form-data" in their formtag.