[Flask] Getting values of Flask-WTF SelectMultipleField?

David Lord davidism at gmail.com
Wed Apr 20 14:20:23 EDT 2016


The same name is supplied multiple times with select multiple fields 
(and this can be done with other fields as well). Use 
|request.form.getlist(name)| to get all values for the given name.

You found an example using Flask-WTF or just straight WTForms and 
conflated it with |request.form| when it was really referring to |form| 
as in “an instance of a |Form|“.

On 04/20/2016 11:15 AM, Alex Hall wrote:

> Hello list,
> I've only been using Flask for a few days, but I'm really likeing it 
> so far. My one question is how to deal with multiple select fields. I 
> can get the value of standard inputs with
> request.form["fieldName"]
> but I can't figure out what to do about multiple select fields. I've 
> googled the topic several different ways, but the only clear answer I 
> found suggested using
> request.form.selectListName.data
> which doesn't do anything.
>
> I need to get the selected values as a list to pass to a database 
> lookup function. For instance, the function expects ["v1", "v2", 
> "v3"]. What's the trick to accessing the selected values of this kind 
> of field? Thanks!
>
> -- 
> Alex Hall
> Automatic Distributors, IT department
> ahall at autodist.com <mailto:ahall at autodist.com>
>
>
> _______________________________________________
> Flask mailing list
> Flask at python.org
> https://mail.python.org/mailman/listinfo/flask

​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20160420/305753ea/attachment.html>


More information about the Flask mailing list