Skip to content

feat: Enhance ChoiceFieldBuilder to support numeric choice keys - #196

Open
Levdbas wants to merge 1 commit into
StoutLogic:masterfrom
Levdbas:fix-int-array-choice-field
Open

Levdbas wants to merge 1 commit into
StoutLogic:masterfrom
Levdbas:fix-int-array-choice-field

Conversation

@Levdbas

@Levdbas Levdbas commented Jul 11, 2025

Copy link
Copy Markdown
Contributor

This PR fixes a bug in the ChoiceFieldBuilder::addChoices() method that prevented us from setting explicit numeric keys without resulting to passing a choice as a Associative array.

The refactored code correctly handles all choice formats:

  • Indexed arrays: ['red', 'blue'] → 'red' => 'red', 'blue' => 'blue'
  • Associative arrays: ['yes' => 'Yes, please...'] → 'yes' => 'Yes, please...'
  • Nested arrays: [['blue' => 'Blue']] → 'blue' => 'Blue'
  • Numeric keys: [1 => 'one', 100 => 'one hundred'] → preserved as-is

Added an additional test to test the new supported format as well.

Fixes #125 at least with the numeric keys.

Tested against #200 and passes.

@Levdbas Levdbas changed the title feat: Enhance ChoiceFieldBuilder to support numeric choice keys with … feat: Enhance ChoiceFieldBuilder to support numeric choice keys Jul 11, 2025
@Levdbas
Levdbas force-pushed the fix-int-array-choice-field branch from 4752495 to 98f495b Compare September 11, 2026 18:13
@Levdbas Levdbas mentioned this pull request Sep 11, 2026
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.

Select 'return_format' only returns label

1 participant