Automattic / Automattic/jetpack

Contact Form: duplicate ids can be specified for form blocks

Open
#15,485 0 comments 0 reactions 0 assignees View on GitHub
[Feature] Forms [Focus] Blocks [Pri] Low Enhancement
Dominant language
PHP
Stars
1.8k
Forks
898
Avg merge
1d 14h
Merged PRs (30d)
790

Description

The Contact Form allows users to provide ids for each form field. These ids must be unique, but the user can enter duplicate ids. Duplicate ids will break the form's expected behavior.

We should consider:
- Displaying a warning if the entered id is not unique.
- Preventing a form with duplicate ids from being published.

#### Steps to reproduce the issue

These steps provide a few examples of how the form can break when duplicate ids are used.

1. On a site with Jetpack active and connected, create or edit a post.
2. Add a Jetpack Form block.
3. The Jetpack Form block shows a few inner blocks by default: Name, Email, Website, and Message. Give the Email and Website blocks the same id.
4. Publish the post.
5. Navigate to the form on your site and complete the form using an email and website with valid formatting. Submit the form.
6. You should an error message: "Email requires a valid email address." You entered a valid email address, so this error should not be displayed.
7. Navigate back to the edit post page.
8. Remove the id from the Email block, and add the same id to the Message block. Now the Website and Message blocks should have the same id. Update the post.
9. Navigate to the post and complete the form using an email and website with valid formatting. Submit the form.
10. On the Message Sent page, notice that the provided website is missing. You can also navigate to wp-admin->Feedback to observe that the provided information is missing.

#### What I expected
The form to properly validate and collect the provided data.

#### What happened instead
When duplicate IDs are used, the form can exhibit unexpected behavior, such as rejecting valid data and overwriting provided data.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the problem in the Jetpack Form block using the duplicate Email, Website, and Message IDs described in the issue. Check the published form and wp-admin Feedback for incorrect validation or missing data; done means duplicate IDs no longer cause valid submissions to be rejected or submitted values to be overwritten.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
full-stack
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.