Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quick_form does not set enctype when FileField present #177

Open
pn2 opened this issue Feb 25, 2018 · 1 comment
Open

quick_form does not set enctype when FileField present #177

pn2 opened this issue Feb 25, 2018 · 1 comment

Comments

@pn2
Copy link

pn2 commented Feb 25, 2018

I read in the docs:

enctype attribute. If None, will automatically be set to multipart/form-data if a FileField is present in the form.

However, in an application I work on, this seems not to be the case. I had to set enctype explicitly in the template (it does not work without the enctype below):

<div class="col-md-4">
   {{ wtf.quick_form(form, enctype="multipart/form-data") }}
</div>

The form declaration is as follows:

class xyzForm(FlaskForm): 
    photo = FileField('Image file', validators=[FileRequired(), FileAllowed(['jpg', 'png'], 'Images only!')])
    submit = SubmitField('Submit')

and it is instantiated with

form = xyzForm()
# also tried: form = xyzForm(CombinedMultiDict((request.files, request.form)))
$ pip3 show flask_bootstrap
Name: Flask-Bootstrap
Version: 3.3.7.1
$ pip3 show flask_wtf
Name: Flask-WTF
Version: 0.14.2
@bianyunzhi95
Copy link

I also have got the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants