Problem/Motivation
Part 3 of splitting #3595219: 3.0 Exploration. This issue completes support for options-based elements — select, radios, checkboxes, tableselect and the term-reference selects — whose option handling is currently incomplete.
Gaps in 3.x:
- The empty/placeholder option of a select (
#empty_option/#empty_value) is not exposed. - Checkboxes' "check all / none" affordance (
#options_all/#options_nonevalues) is not represented. - Option randomization (
#options_randomize) is neither exposed nor handled — randomized option order leaks into the resolved list non-deterministically. - Nested (grouped) options lose their group label.
- Options of disabled elements are dropped.
- The "options display" settings (how options are laid out, e.g. side-by-side) are not exposed.
- Table-like elements (
tableselect) and term-reference selects do not resolve their real option set.
Proposed resolution
- Introduce a GraphQL interface for select-style elements and expose the empty option (value + label).
- Introduce a checkboxes interface exposing the "all" / "none" option values.
- Expose
optionsRandomizeand, when resolving, "unshuffle" the options to a stable order so the exposed list is deterministic while still signalling that randomization is configured. - Carry the
groupLabelthrough nested option groups onWebformElementOption. - Resolve options even when the element is disabled.
- Expose the options-display setting via a
WebformOptionsDisplayenum. - Resolve real options for table-like elements and for
WebformElementWebformTermSelect(including the existing depth handling).
All option resolution goes through src/Plugin/GraphQL/DataProducer/WebformElementOptions.php, with the per-element types/interfaces generated in src/WebformSchemaBuilder.php and wired in WebformExtension.php.
Remaining tasks
- Add the select/checkboxes interfaces and the
WebformOptionsDisplayenum (src/Enum/WebformOptionsDisplay.php); wire intoWebformSchemaBuilder.phpandWebformExtension.php. - Extend
WebformElementOptions.php: empty option, all/none, randomize + unshuffle, groupLabel, disabled-element options, table-like and term-select option resolution. - Tests:
CheckboxesTest,RadiosTest,SelectOptionGroupsTest,DisabledOptionsTest,OptionsDisplayTest,RandomizedOptionsTest,TableSelectTest,TermSelectTest, plus the matchingtests/queries/*.gqlfixtures and additions to the shared test-form fixture.
API changes
Additive: new select/checkboxes interfaces and fields (empty option, all/none values, optionsRandomize, groupLabel, options display), and a new WebformOptionsDisplay enum. No fields removed.
Release notes snippet
Options-based elements (select, radios, checkboxes, tableselect, term selects) now expose their empty option, check-all/none values, options-display setting and group labels, resolve options even when disabled, and report option randomization with a deterministic order.
Issue fork graphql_webform-3598973
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
pfrenssen