Skip to content

Conversation

@enejb
Copy link
Member

@enejb enejb commented Nov 12, 2025

Fixes FORMS-394

Proposed changes:

  • Make sure that we get the correct requireText from the option block.
  • Added tests to cover this case for the checkbox field.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

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?

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.
@enejb enejb requested review from a team and Copilot November 12, 2025 16:14
@enejb enejb added [Type] Bug When a feature is broken and / or not performing as intended [Status] Needs Review This PR is ready for review. [Package] Forms labels Nov 12, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 12, 2025

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 fix/checkbox-missing-required-text branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/checkbox-missing-required-text

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
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 a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ 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!

Copilot finished reviewing on behalf of enejb November 12, 2025 16:15
Copy link
Contributor

Copilot AI left a 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 requiredText from 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 requiredText attribute

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 );
Copy link

Copilot AI Nov 12, 2025

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.

Suggested change
$atts['requiredText'] = $inner_block['attrs']['requiredText'] ?? ( $atts['requiredText'] ?? null );
$atts['requiredText'] = $inner_block['attrs']['requiredText'] ?? ( $atts['requiredText'] ?? null );

Copilot uses AI. Check for mistakes.
@jp-launch-control
Copy link

jp-launch-control bot commented Nov 12, 2025

Code Coverage Summary

Cannot generate coverage summary while tests are failing. 🤐

Please fix the tests, or re-run the Code coverage job if it was something being flaky.

Full summary · PHP report · JS report

Copy link
Contributor

@edanzer edanzer left a 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.

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

Labels

[Feature] Contact Form [Package] Forms [Status] Needs Review This PR is ready for review. [Tests] Includes Tests [Type] Bug When a feature is broken and / or not performing as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants