Skip to content

Conversation

@Levdbas
Copy link

@Levdbas Levdbas commented Jul 11, 2025

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.

@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
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