We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The documentation on Form states:
Form
obj – If formdata is empty or not provided, this object is checked for attributes matching form field names, which will be used for field values
However, with BooleanFields this isn't true: If formdata is empty, a BooleanField's data will be set to False, no matter what the value of obj is.
False
obj
>>> import wtforms >>> class F(wtforms.Form): ... foo = wtforms.BooleanField() ... >>> class DummyObj: ... def __init__(self): ... self.foo = True ... >>> class DummyPostData(dict): ... def getlist(self, key): ... v = self[key] ... if not isinstance(v, (list, tuple)): ... v = [v] ... return v ... >>> f = F(formdata=DummyPostData(), obj=DummyObj()) >>> f.foo.data False >>> f.foo.object_data True
>>> f = F(formdata=DummyPostData(), obj=DummyObj()) >>> f.foo.data True >>> f.foo.object_data True
The text was updated successfully, but these errors were encountered:
Duplicate of #662, #402, or one of these.
Sorry, something went wrong.
No branches or pull requests
The documentation on
Form
states:However, with BooleanFields this isn't true: If formdata is empty, a BooleanField's data will be set to
False
, no matter what the value ofobj
is.Actual Behavior
Expected Behavior
Environment
The text was updated successfully, but these errors were encountered: