[Flask] Access form data in view function

Alex Hall ahall at autodist.com
Thu Apr 21 08:13:13 EDT 2016


Hello all,
Further to my question about multiple select fields yesterday, how does a
view function access form data in general? I know I use the global(?)
request object's "form" property, but beyond that I'm not sure. I can
access StringField values (I'm using WTF) by using request.form.fieldID.
But single select fields, multiple select fields, the status of checkboxes
or radio buttons, and so on I can't work out or find online. One resource
said, for checkboxes, to use request.form.getlist("checkboxID"), but that
gave me an empty list despite that checkbox being checked. What am I
missing? I know people usually use validators, but I need the values and
statuses of elements in my form-processing view function because I'm
dynamically constructing an SQL query based on the form's information.

-- 
Alex Hall
Automatic Distributors, IT department
ahall at autodist.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20160421/aa948936/attachment-0001.html>


More information about the Flask mailing list