Skip to content

Forms: conditional logic (4/5) — server-side render and validation - #50979

Open
enejb wants to merge 1 commit into
add/forms-conditional-logic-frontendfrom
add/forms-conditional-logic-server
Open

Forms: conditional logic (4/5) — server-side render and validation#50979
enejb wants to merge 1 commit into
add/forms-conditional-logic-frontendfrom
add/forms-conditional-logic-server

Conversation

@enejb

@enejb enejb commented Jul 31, 2026

Copy link
Copy Markdown
Member

Part 4 of 5. This series splits #50938 into reviewable pieces. Each PR is based on the previous one, so the diff shown here is incremental.

  1. Forms: conditional logic (1/5) — vocabulary and feature flag #50976 — vocabulary and feature flag
  2. Forms: conditional logic (2/5) — the resolver, in JS and PHP #50977 — the resolver, in JS and PHP
  3. Forms: conditional logic (3/5) — apply in the browser #50978 — apply in the browser
  4. Forms: conditional logic (4/5) — server-side render and validation #50979 — server-side render and validation
  5. Forms: conditional logic (5/5) — the editor panel #50980 — the editor panel

Proposed changes

Part 4 of 5 splitting #50938. Two problems the browser cannot solve on its own.

A required field that conditional logic hides used to block submission. It was invalid, but the visitor could not see it to fill it in. Validation now skips fields the rules hide, evaluated server-side from the submitted values rather than trusting anything the browser reports. Parse-time validation is deferred for conditional fields, which otherwise wrote a static error before any answers existed.

Fields that start hidden used to render visible and then disappear once the runtime booted. Initial visibility is now resolved while rendering and stamped onto the markup, so the form is correct in its first paint. Values prefilled through the query string are taken into account, so a link that prefills the field a rule depends on renders the resulting state directly.

Only hidden fields are dropped from the stored feedback, so a response records what the visitor was actually asked.

Related product discussion/links

Does this pull request change what data or activity we track or use?

A form response no longer stores values for fields that conditional logic hid at submit time. Nothing new is collected.

Testing instructions

With the flag on and a form that hides a required field:

  • Submit without revealing the hidden required field → submission succeeds, no error about a field you cannot see.
  • Reveal it, leave it empty, submit → validation fails as normal.
  • Load a form whose first field is hidden by a rule → it must not flash visible before disappearing. Throttle the network to make a flash obvious.
  • Load the same form with ?fieldname=value prefilling the field a rule depends on → the dependent field renders in its resulting state immediately.
  • Check the stored response contains only fields that were visible.

Also: jetpack test php packages/forms.

Two problems the browser cannot solve on its own.

A required field that conditional logic hides used to block submission: it was
invalid, but the visitor could not see it to fill it in. Validation now skips
fields the rules hide, evaluated server-side from the submitted values rather
than trusting anything the browser reports. Parse-time validation is deferred
for conditional fields, which otherwise wrote a static error before any answers
existed.

Fields that start hidden used to render visible and then disappear once the
runtime booted. The initial visibility is now resolved while rendering and
stamped onto the markup, so the form is correct in its first paint. Values
prefilled through the query string are taken into account, so a link that
prefills the field a rule depends on renders the resulting state directly.

Only hidden fields are dropped from the stored feedback, so a response records
what the visitor was actually asked.
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the add/forms-conditional-logic-server branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/forms-conditional-logic-server

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@jp-launch-control

Copy link
Copy Markdown

Code Coverage Summary

No summary data is available for parent commit 5a56544, so cannot calculate coverage changes. 😴

If that commit is a feature branch rather than a trunk commit, this is expected. Otherwise, this should be updated once coverage for 5a56544 is available.

Full summary · PHP report · JS report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant