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
source
share