Problem/Motivation

Part 4 of splitting #3595219: 3.0 Exploration. This issue adds the "other" option variants (select_other, radios_other, checkboxes_other, buttons_other) and fixes multiple-value / custom-composite handling, both for querying and for submission.

Gaps in 3.x:

  • "Other" elements are not supported: the free-text "other" option, its label (#other__option_label) and its placement in the option list are not exposed, and submissions that use the "other" value are not accepted/validated.
  • A composite element containing an "other" sub-element cannot be submitted.
  • An element's description is dropped when the element is configured as #multiple.
  • multipleValues is resolved incorrectly for custom composite elements.

Proposed resolution

  • Support the "other" element family: add a webform_element_other data producer that resolves the other-option label and value, and expose them on the relevant element types. Because "other" elements wrap an options element, this builds on the options work in #3598973: Options/selection elements.
  • Accept and validate submissions that use the "other" free-text value, including when nested inside a composite element.
  • Resolve the description for elements regardless of the #multiple setting.
  • Correctly resolve multipleValues for custom composite elements.

Submission handling changes live in src/Plugin/GraphQL/DataProducer/WebformSubmit.php; element resolution in WebformElementOther.php (new), WebformElementProperty.php, WebformElementMetadata.php and WebformElementMultipleValues.php.

Remaining tasks

  • Add src/Plugin/GraphQL/DataProducer/WebformElementOther.php and wire the other-option fields into WebformSchemaBuilder.php / WebformExtension.php.
  • Resolve description independent of #multiple in WebformElementProperty.php.
  • Fix multipleValues for custom composites in WebformElementMultipleValues.php.
  • Accept/validate "other" values (incl. nested-in-composite) in WebformSubmit.php.
  • Tests: OtherTest, CustomCompositeTest, MultipleValuesTest, and mutation tests FormSubmissionOtherTest, FormSubmissionNestedOtherTest, plus the other.gql fixture and shared test-form additions.

API changes

Additive: support for *_other element types and their other-option fields; submission accepts the "other" free-text value. Fixes description and multipleValues resolution. No fields removed.

Release notes snippet

"Other" option elements (select/radios/checkboxes/buttons with a free-text "other" choice) are now supported for both querying and submission, including when nested in composite elements. Element descriptions and multipleValues are now resolved correctly for multiple-value and custom-composite elements.

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’s picture

Title: Options/selection elements » "Other" + composite/multiple submission

  • pfrenssen committed 4939ecd2 on 3.x
    feat: #3598977 "Other" + composite/multiple submission
    
    By: dulnan
    By:...
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.