Cannot append_entry FieldList in Flask-wtf more than one

I have a form with flask-wtf for uploading some image, also the file field can be multiple

my form:

 class ComposeForm(Form):
     attachment = FieldList(FileField(_('file')), _('attachment'))
     add_upload = SubmitField(_('Add upload'))

my opinion:

  if form.validate_on_submit():
         if form.add_upload.data:
             form.attachment.append_entry()
             return render_template('mailbox/compose.html', form=form)
         else:
             form.attachment.append_entry()

my template:

<form method="POST" enctype="multipart/form-data" action=".">
                {% for field in form %}
                {{field}}
                {% endfor %}
</div>

when I use enctype="multipart/form-data"the form append_entrydoes not work, add another field again click add_upload, but after the update I have only one field (not two)

How can i fix this? no error, I think because of enctype wtform forget how many fields I have to add more: D

+5
source share
1 answer

You call append_entry, not enough data.

From the documentation :

append_entry ([data])

.

, , formdata .

, , pop_entry. , , , form.attachment.entries. ? , ?

+4

All Articles