Problem/Motivation

Part 2 of splitting #3595219: 3.0 Exploration. This issue covers form-level rendering correctness: conditional #states, multi-page (wizard) forms, and building a form for a source entity with query-string prepopulation. These are grouped because they all concern what a built form instance actually renders for a given context, rather than any single element type.

Problems addressed:

  • Inverted #states conditions. Conditional logic such as "visible when X is empty" / "invisible when checked" is emitted with the wrong trigger or an empty value, so consumers rebuilding conditional visibility get incorrect behaviour.
  • States lost on multi-page (wizard) forms. When a webform is split into wizard pages, element #states are not resolved, so conditional logic disappears for any non-trivial form.
  • No source entity / prepopulation support. A built form often depends on a source entity and on values prepopulated from the query string (Webform's ?element=value prepopulation). The module cannot build a form for a given source entity or apply query-string prepopulation, and the resulting cacheability (per-URL, per source entity) is not represented.

Proposed resolution

  • Fix #states resolution so negated conditions (empty / unchecked / unfilled) emit the correct trigger and value, in src/Plugin/GraphQL/DataProducer/WebformElementState.php (and its metadata wiring).
  • Resolve #states across wizard pages so conditional logic survives multi-page forms.
  • Build the form for an optional source entity and apply Webform's query-string prepopulation, exposing the prepopulated default values and bubbling the correct cache metadata (URL / source-entity cache tags and contexts) into the response — building on the cacheability foundation in #3598935: Improve cacheability and rendering.

Remaining tasks

  • Correct negated #states trigger/value handling in WebformElementState.php; cover with tests/src/Kernel/DataProducer/WebformElementStateTest.php.
  • Resolve states across wizard pages; cover with tests/src/Kernel/Element/WizardPageStatesTest.php.
  • Pass the source entity into the form build and apply query-string prepopulation in src/Plugin/GraphQL/DataProducer/WebformElements.php / WebformForm.php and the schema wiring.
  • Tests: WebformPrepopulateTest, WebformSourceEntityCacheMetadataTest, WebformSourceEntityTokensTest, plus the prepopulate.gql / source_entity_*.gql query fixtures.

API changes

Additive and correctness-only: conditional #states are now reported correctly (including negated conditions and on wizard forms), and a form can be built for a source entity with query-string prepopulation, with correct cache metadata. No fields are removed.

Release notes snippet

Conditional element logic (#states) is now resolved correctly, including negated conditions and on multi-page (wizard) forms. Forms can be built for a source entity and prepopulated from the query string, with correct cache metadata on the response.

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

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.