[Flask] Form with no validators failing validation

Alex Hall ahall at autodist.com
Tue Apr 26 08:44:05 EDT 2016


In the form class, simply put
 myField.label.text = "some label text"

Right away, Flask errors out:
AttributeError: 'UnboundField' object has no attribute 'label'

That's why I assumed I had to do it after instantiating the form. I even
tried putting all my class properties in __init__, assigning them all to
self (self.myField = StringField()), and then using
self.myField.label.text, but I got the same error. The only difference is
that the error shows on the webpage rather than in the command line. As
usual, I'm probably missing something obvious. :)

On Tue, Apr 26, 2016 at 3:08 AM, Andrea D'Amore <and.damore at gmail.com>
wrote:

> On 25 April 2016 at 22:01, Alex Hall <ahall at autodist.com> wrote:
> > Because it worked.  I know there must be an easier way,
>
> I'd say in the form definition, as you are already doing with placeholders.
>
> > but I couldn't set it right in the form class as the properties didn't
> exist yet and so lacked the label property.
>
> Can you provide a SSCCE (short self-contained correct example [1] -
> this definitely needs a better name…) of this issue?
>
> [1]: http://sscce.org
>
> --
> Andrea
>



-- 
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/20160426/dc6a4006/attachment.html>


More information about the Flask mailing list