fix(format-spec): read every option shape a select can be written in - #50
Merged
sylvesterdamgaard merged 1 commit intoSep 9, 2026
Conversation
selectSpec() handled two of the three shapes Statamic accepts: a key => label map and a flat list of scalars. It missed the list of ['key' => ..., 'value' => ...] maps, which is what the Control Panel writes and therefore the common one in practice. Those entries are arrays under numeric keys, so the is_scalar filter dropped them all and allowed_values came back empty. A client reading the spec then sees a field it knows is an enum, with no values to choose from, and has to guess or fall back to include_config. Mirror Fieldtypes\HasSelectOptions::getOptions() so all three shapes resolve, including selects, radios and button groups. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
11 tasks
This was referenced Sep 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
selectSpec()handled two of the three option shapes Statamic accepts: akey => labelmap and a flat list of scalars. It missed the list of['key' => ..., 'value' => ...]maps, which is what the Control Panel writes and therefore the common one in practice. Those entries are arrays under numeric keys, so theis_scalarfilter dropped them all andallowed_valuescame back empty.Mirrors
Fieldtypes\HasSelectOptions::getOptions()so all three shapes resolve.Type of Change
Related Issue
None. Found writing a page-builder entry, where every
selectandbutton_groupin the blueprint reported"allowed_values": []while the field config alongside it carried the options in full.Testing
composer test)composer quality)tests/Unit/FieldFormatSpecTest.php— 6 cases: each of the three shapes, a non-string key cast to string, a select with no options, andenum_arraystill reported for a multiple select.Verified against
main: 3 of the 6 fail there, all pass here. The other 3 are regression guards for the two shapes that already worked.Full gate green — pint, PHPStan level 9, 1112 tests / 5611 assertions.
Environment
Checklist
Notes
The effect is worse than one empty array: a client sees a field it knows is an enum with nothing to choose from, so it either guesses or omits the field. On a
selectdriving a template branch, omitting it renders nothing, and the write still reports success.Two things deliberately left out of scope.
cast_booleansselects store real booleans rather than the string values reported here, which the spec does not yet express. And the option labels are dropped, though they would help a client choose between values it cannot otherwise interpret.