Problem/Motivation

Part 3 of splitting #3595219: 3.0 Exploration. This issue completes support for options-based elementsselect, 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_none values) 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 optionsRandomize and, when resolving, "unshuffle" the options to a stable order so the exposed list is deterministic while still signalling that randomization is configured.
  • Carry the groupLabel through nested option groups on WebformElementOption.
  • Resolve options even when the element is disabled.
  • Expose the options-display setting via a WebformOptionsDisplay enum.
  • 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 WebformOptionsDisplay enum (src/Enum/WebformOptionsDisplay.php); wire into WebformSchemaBuilder.php and WebformExtension.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 matching tests/queries/*.gql fixtures 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.

Command icon 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

pfrenssen created an issue. See original summary.

  • pfrenssen committed fd0535aa on 3.x
    feat: #3598973 Options/selection elements
    
    By: dulnan
    By: pfrenssen
    
pfrenssen’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.