Skip to content

[6.x] Forms 2: Don't pre-select choice options keyed 0 - #16005

Merged
jasonvarga merged 1 commit into
6.xfrom
fix-choice-field-zero-selection
Nov 27, 2026
Merged

jasonvarga merged 1 commit into
6.xfrom
fix-choice-field-zero-selection

Conversation

@duncanmcclean

Copy link
Copy Markdown
Member

This pull request fixes an issue where Dropdown, Multiple Choice, Yes/No and Image Choice fields would pre-select the option keyed 0 when the field had no value, so an untouched field would submit 0 as if the user had picked it.

This was happening because the front-end views compared the value to each option key loosely (==). Since options are now stored with sequential keys, most choice fields have a 0 option.

This PR fixes it by comparing them as strings, in both the Antlers and Blade views. This PR also simplifies the Opinion Scale views to use the same comparison.

Amp thread: https://ampcode.com/threads/T-01a20811-53bb-76c1-9081-e60dba05c2c8

Base automatically changed from forms-2 to 6.x November 24, 2026 17:49
@jasonvarga
jasonvarga force-pushed the fix-choice-field-zero-selection branch from f19e922 to b92f06a Compare November 24, 2026 20:36
@jasonvarga
jasonvarga merged commit e577993 into 6.x Nov 27, 2026
64 checks passed
@jasonvarga
jasonvarga deleted the fix-choice-field-zero-selection branch November 27, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants