Repository navigation
Implement ButtonField - #892
Merged
Merged
Conversation
ThiefMaster
reviewed
May 3, 2026
|
|
||
| The field's label is also used as the rendered HTML ``value`` of the submit | ||
| control. Its WTForms data is boolean: the field is ``True`` when that | ||
| submit button was pressed, and ``False`` otherwise. |
There was a problem hiding this comment.
Is it actually False, or rather None?
Member
Author
There was a problem hiding this comment.
False, but maybe it worth mentioning that if the button is clicked but have an empty HTML value, then its wtforms value is False.
>>> from wtforms import Form, SubmitField
>>> from werkzeug.datastructures import MultiDict
>>> class F(Form):
... submit = SubmitField("Save")
...
>>> f = F(MultiDict({"submit": "Save"}))
>>> f.validate()
True
>>> f.submit.data
True
>>> f = F(MultiDict({"submit": ""}))
>>> f.validate()
True
>>> f.submit.data
False
>>> f = F(MultiDict({}))
>>> f.validate()
True
>>> f.submit.data
False
azmeuk
force-pushed
the
784-button
branch
2 times, most recently
from
May 3, 2026 16:07
f6c8274 to
f2de571
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement
ButtonFieldinheritingStringFieldas an alternative toSubmitFieldthat inheristsBooleanField. It uses the<button type="submit">tag, which allow the widget to have a label different than the value.fixes #784