Skip to content

Commit 273d03b

Browse files
authored
Merge pull request #810 from azmeuk/issue-682-w3c-conformance
remove `required` flag usage on some widgets
2 parents 3cd4e34 + 9b01642 commit 273d03b

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

CHANGES.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ Unreleased
99
dutch, kazakh, swedish, turkish, slovak, ukranian, spanish, french.
1010
- Move the repository to the pallets-eco organization.
1111
- Stop supporting Python 3.9 and start supporting Python 3.13 :pr:`855`
12+
- Removed `required` flag support from :class:`~fields.HiddenWidget`,
13+
:class:`~fields.RangeWidget` and :class:`~fields.SelectWidget` to
14+
conform to W3C :pr:`810`
1215

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

35-
3638
Version 3.1.0
3739
-------------
3840

src/wtforms/widgets/core.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ class Input:
163163
"""
164164

165165
html_params = staticmethod(html_params)
166-
validation_attrs = ["required", "disabled"]
167166

168167
def __init__(self, input_type=None):
169168
if input_type is not None:
@@ -232,6 +231,7 @@ class HiddenInput(Input):
232231
"""
233232

234233
input_type = "hidden"
234+
validation_attrs = ["disabled"]
235235

236236
def __init__(self, *args, **kwargs):
237237
super().__init__(*args, **kwargs)
@@ -246,6 +246,7 @@ class CheckboxInput(Input):
246246
"""
247247

248248
input_type = "checkbox"
249+
validation_attrs = ["required", "disabled"]
249250

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

264265
input_type = "radio"
266+
validation_attrs = ["required", "disabled"]
265267

266268
def __call__(self, field, **kwargs):
267269
if field.checked:
@@ -301,6 +303,7 @@ class SubmitInput(Input):
301303
"""
302304

303305
input_type = "submit"
306+
validation_attrs = ["required", "disabled"]
304307

305308
def __call__(self, field, **kwargs):
306309
kwargs.setdefault("value", field.label.text)
@@ -568,7 +571,7 @@ class RangeInput(Input):
568571
"""
569572

570573
input_type = "range"
571-
validation_attrs = ["required", "disabled", "max", "min", "step"]
574+
validation_attrs = ["disabled", "max", "min", "step"]
572575

573576
def __init__(self, step=None):
574577
self.step = step
@@ -585,3 +588,4 @@ class ColorInput(Input):
585588
"""
586589

587590
input_type = "color"
591+
validation_attrs = ["disabled"]

0 commit comments

Comments
 (0)