Skip to content

Commit

Permalink
Merge pull request #810 from azmeuk/issue-682-w3c-conformance
Browse files Browse the repository at this point in the history
remove `required` flag usage on some widgets
  • Loading branch information
azmeuk authored Oct 11, 2024
2 parents 3cd4e34 + 9b01642 commit 273d03b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Unreleased
dutch, kazakh, swedish, turkish, slovak, ukranian, spanish, french.
- Move the repository to the pallets-eco organization.
- Stop supporting Python 3.9 and start supporting Python 3.13 :pr:`855`
- Removed `required` flag support from :class:`~fields.HiddenWidget`,
:class:`~fields.RangeWidget` and :class:`~fields.SelectWidget` to
conform to W3C :pr:`810`

Version 3.1.2
-------------
Expand All @@ -32,7 +35,6 @@ Released 2023-11-01
- Restored support for 3-items tuple return value from `iter_choices`
:pr:`816`


Version 3.1.0
-------------

Expand Down
8 changes: 6 additions & 2 deletions src/wtforms/widgets/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ class Input:
"""

html_params = staticmethod(html_params)
validation_attrs = ["required", "disabled"]

def __init__(self, input_type=None):
if input_type is not None:
Expand Down Expand Up @@ -232,6 +231,7 @@ class HiddenInput(Input):
"""

input_type = "hidden"
validation_attrs = ["disabled"]

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand All @@ -246,6 +246,7 @@ class CheckboxInput(Input):
"""

input_type = "checkbox"
validation_attrs = ["required", "disabled"]

def __call__(self, field, **kwargs):
if getattr(field, "checked", field.data):
Expand All @@ -262,6 +263,7 @@ class RadioInput(Input):
"""

input_type = "radio"
validation_attrs = ["required", "disabled"]

def __call__(self, field, **kwargs):
if field.checked:
Expand Down Expand Up @@ -301,6 +303,7 @@ class SubmitInput(Input):
"""

input_type = "submit"
validation_attrs = ["required", "disabled"]

def __call__(self, field, **kwargs):
kwargs.setdefault("value", field.label.text)
Expand Down Expand Up @@ -568,7 +571,7 @@ class RangeInput(Input):
"""

input_type = "range"
validation_attrs = ["required", "disabled", "max", "min", "step"]
validation_attrs = ["disabled", "max", "min", "step"]

def __init__(self, step=None):
self.step = step
Expand All @@ -585,3 +588,4 @@ class ColorInput(Input):
"""

input_type = "color"
validation_attrs = ["disabled"]

0 comments on commit 273d03b

Please sign in to comment.