Access Multiselect Form Field in Flask
You want to use the getlist()
function to get a list of values:
multiselect = request.form.getlist('mymultiselect')
You do not need to add []
to the name to make this work; in fact, the []
will not help, don't use it at all.
> In sometimes, If you are using Ajax POST method then check the parameter name in network tab. Check the image attached that describes how to verify the parameter names.
In Flask view:
you can access the list responce based on parameter name.
request.form.getlist('mymultiselect[]')
or
request.form.getlist('mymultiselect')