-
Notifications
You must be signed in to change notification settings - Fork 815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Forms: form validation does not work when JavaScript is disabled #41942
Comments
I see this bug seems to have been introduced fairly recently via #40998. Basically the incrementing id means forms aren't idempotent, if the same form is run through the rendering code twice it'll receive a different id and cause a mismatch.. @simison just making you aware of this issue. It seems very low priority to me and I can push a small fix to solve the 404, but I don't plan to look much deeper. I just need to be able to test that the block based field has parity with the shortcode for #41840, and this bug was blocking me. That said, if the form ids are brittle, they might cause other problems. I personally think a more solid solution is to use a uuid style id that's stored with the form markup, but I might not be aware of some of the constraints. |
Another thing related to this that I've discovered on my journey through the form block. If using the form block in a post, the form submission expects the form id to be the post id. This code here is passing the jetpack/projects/packages/forms/src/contact-form/class-contact-form-plugin.php Lines 732 to 740 in 49183ea
That
This isn't going to work so well with the way the id is now a lot more complex when initially set:
It's really surprising that the id is being suddenly converted to a post id this way. |
Impacted plugin
Jetpack
Quick summary
The Form block (and possibly shortcode) usually performs JavaScript form validation. See the accessible-form.js file.
There's also a lot of PHP code for form validation, which is (I assume) for when JavaScript is disabled. See the
Contact_Form_Field->validate
method:jetpack/projects/packages/forms/src/contact-form/class-contact-form-field.php
Lines 204 to 266 in 7a3559d
This PHP validation doesn't seem to work, at least on a block theme. Submitting a form that has validation errors sends the user to a 404 page.
If this needs to be supported, then it looks like something to be fixed. Alternatively, the code could be removed if form validation with JS disabled isn't a feature that needs to be kept.
Steps to reproduce
Expected: The form shows validation errors

Actual: A 404 page is shown. This seems to be because
?page=1
is appended to the URL.Site owner impact
Fewer than 20% of the total website/platform users
Severity
Minor
What other impact(s) does this issue have?
No revenue impact
If a workaround is available, please outline it here.
No response
Platform (Simple and/or Atomic)
Self-hosted
The text was updated successfully, but these errors were encountered: