-
Notifications
You must be signed in to change notification settings - Fork 839
Forms: Pass requiredText from option block to checkbox field #45897
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
base: trunk
Are you sure you want to change the base?
Conversation
Adds support for passing the requiredText attribute from the jetpack/option inner block to the checkbox field in the contact form plugin. Includes a new test to verify that requiredText is correctly rendered in the generated shortcode.
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue where the requiredText attribute from a jetpack/option block wasn't being passed through to checkbox fields correctly.
- Passes
requiredTextfrom option block attributes to checkbox field shortcode attributes - Adds test coverage for checkbox fields with custom required text
- Updates existing test data provider to include the new
requiredTextattribute
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| projects/packages/forms/src/contact-form/class-contact-form-plugin.php | Extracts requiredText from option block attributes and passes it to the checkbox field |
| projects/packages/forms/tests/php/contact-form/Contact_Form_Plugin_Test.php | Adds test for checkbox field with custom required text and updates data provider |
| projects/packages/forms/changelog/fix-checkbox-required-text-option-block | Documents the bug fix and test coverage addition |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $atts['optionclasses'] .= isset( $option_attrs['class'] ) ? ' ' . $option_attrs['class'] : ''; | ||
| $atts['optionstyles'] = $option_attrs['style'] ?? null; | ||
|
|
||
| $atts['requiredText'] = $inner_block['attrs']['requiredText'] ?? ( $atts['requiredText'] ?? null ); |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The alignment and spacing of the assignment operators are inconsistent. Line 578 has extra spaces before the = operator ($atts['requiredText'] =) while lines 572-576 have proper alignment. This should be consistently formatted like the other lines above it.
| $atts['requiredText'] = $inner_block['attrs']['requiredText'] ?? ( $atts['requiredText'] ?? null ); | |
| $atts['requiredText'] = $inner_block['attrs']['requiredText'] ?? ( $atts['requiredText'] ?? null ); |
Code Coverage SummaryCannot generate coverage summary while tests are failing. 🤐 Please fix the tests, or re-run the Code coverage job if it was something being flaky. |
edanzer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I tested on trunk to confirm the issue, then tested to confirm the issue is resolved with this PR. Change is straightforward. Tests pass.
Fixes FORMS-394
Proposed changes:
Other information:
Jetpack product discussion
See FORMS-394
Does this pull request change what data or activity we track or use?
No
Testing instructions:
Create a form with a checkbox and alter the require text to be something other then required.
Notice that on the frontend it shows up as expected.
Make sure that there are no regressions with the options field.
And thre regular checkbox field.
Do the test still pass?