Skip to content

[rejected AI] Preserve explicitly empty choice labels - #937

Closed
xianjianlf2 wants to merge 1 commit into
pallets-eco:mainfrom
xianjianlf2:fix/preserve-empty-choice-labels
Closed

xianjianlf2 wants to merge 1 commit into
pallets-eco:mainfrom
xianjianlf2:fix/preserve-empty-choice-labels

Conversation

@xianjianlf2

Copy link
Copy Markdown

Explicitly empty choice labels are currently replaced with the choice value when rendering selects or radio buttons. For example, SelectField(choices=[('blank', '')]) renders an option displaying blank on main, whereas WTForms 3.2.1 renders an empty label.

Use the value fallback only when the label is None, preserving empty strings in option subfields, the Select widget, and the pre-3.3 render_option compatibility adapter. Omitted labels still default to the choice value.

Add regressions for select, multiple-select, and radio fields with grouped and ungrouped choices, plus a legacy custom renderer. All 7 new cases fail before the fix. Afterward, all 533 tests and all prek run --all-files checks pass. The original behavior was also verified against an isolated WTForms 3.2.1 installation.

AI-assisted implementation and validation.

@davidism

davidism commented Sep 8, 2026

Copy link
Copy Markdown
Member

@davidism davidism closed this Sep 8, 2026
@davidism davidism changed the title Preserve explicitly empty choice labels [rejected AI] Preserve explicitly empty choice labels Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants