diff --git a/CHANGES.rst b/CHANGES.rst index f34903fc9..82d3f6d4a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,8 @@ Version 3.2.1 Released 2024-10-21 - Fix :class:`~fields.SelectMultipleBase` import. :issue:`861` :pr:`862` +- Support for mixture of grouped and non-grouped choices in + :class:`~widgets.Select`. :pr:`870` Version 3.2.0 ------------- diff --git a/src/wtforms/widgets/core.py b/src/wtforms/widgets/core.py index 832918e82..dd000d58e 100644 --- a/src/wtforms/widgets/core.py +++ b/src/wtforms/widgets/core.py @@ -343,7 +343,11 @@ class Select: It also must provide a `has_groups()` method which tells whether choices are divided into groups, and if they do, the field must have an `iter_groups()` method that yields tuples of `(label, choices)`, where - `choices` is a iterable of `(value, label, selected)` tuples. + `choices` is a iterable of `(value, label, selected)` tuples. If `label` + is `None`, the choices are rendered next to the groups. + + .. versionadded:: 3.2.1 + Support for mixture of grouped and ungrouped options. """ validation_attrs = ["required", "disabled"] @@ -363,12 +367,14 @@ def __call__(self, field, **kwargs): html = [f"' + '' + '' + '' + '' + ) + + def test_render_option(): # value, label, selected assert (