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
descriptionis dropped when the element is configured as#multiple. multipleValuesis resolved incorrectly for custom composite elements.
Proposed resolution
- Support the "other" element family: add a
webform_element_otherdata 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
descriptionfor elements regardless of the#multiplesetting. - Correctly resolve
multipleValuesfor 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.phpand wire the other-option fields intoWebformSchemaBuilder.php/WebformExtension.php. - Resolve
descriptionindependent of#multipleinWebformElementProperty.php. - Fix
multipleValuesfor custom composites inWebformElementMultipleValues.php. - Accept/validate "other" values (incl. nested-in-composite) in
WebformSubmit.php. - Tests:
OtherTest,CustomCompositeTest,MultipleValuesTest, and mutation testsFormSubmissionOtherTest,FormSubmissionNestedOtherTest, plus theother.gqlfixture 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.
Issue fork graphql_webform-3598977
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 #2
pfrenssenComment #5
pfrenssen