Skip to content

[Block] Add Form templates #171

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

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open

Conversation

iamdharmesh
Copy link
Collaborator

@iamdharmesh iamdharmesh commented Jul 17, 2025

Description of the Change

PR adds form templates to the Mailchimp List Subscribe Form block using the block variations and variation picker. A form template is essentially a form with a predefined set of fields. The PR introduces the following initial form templates:

  • Quick Signup: Email
  • Personal Signup: First name, Last name, Email
  • Contact Form: First name, Last name, Email, Phone, Address
  • Default form - This will be a default form, fields visibility will be based on the global settings

Note

For the selected template, the form will still include the other form fields in a hidden state, providing flexibility to show or hide additional form fields.

Screenshot 2025-07-17 at 5 48 18 PM

Closes #170

How to test the Change

  1. Create a page.
  2. Insert the Mailchimp List Subscribe Form block. You will be presented with form template options to choose from.
  3. Select each template one by one and verify that the form is inserted correctly with the appropriate form fields.
  4. Show or hide form fields and ensure it works as expected.
  5. Visit the front end and make sure the form functions correctly.

Changelog Entry

Added - Form templates to the Mailchimp List Subscribe Form block, allowing users to quickly insert and publish a form.

Credits

Props @jeffpaul, @dkotter, @vikrampm1, Romain Deville, @iamdharmesh

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@iamdharmesh iamdharmesh self-assigned this Jul 17, 2025
@github-actions github-actions bot added this to the 2.0.0 milestone Jul 17, 2025
export const variations = [
{
name: 'email-only-form',
title: __('Quick Signup (Email Only)', 'mailchimp'),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dkotter @jeffpaul Adding a note here to discuss and finalize the name of Form templates. Also, we are using the form header text from the settings, I think we should consider update is based on the form template. what do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we are using the form header text from the settings, I think we should consider update is based on the form template. what do you think?

Hmm.. not sure honestly. On one hand, it's not likely that the header text will be accurate for all of these different variations and so setting specific ones for each makes sense. But because we have a global setting for this, the user expectation here is probably for that text to be used. I don't think I want to introduce new settings for each variation though.

Because this text can be edited in the block, I think I may be fine with just using the same text for each variation and a user can edit that at the block level if desired. But open to differing opinions here, maybe we use the header text from settings for the default variation but then have hardcoded titles for the rest?

Copy link
Collaborator Author

@iamdharmesh iamdharmesh Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I want to introduce new settings for each variation though.

Yes, no new settings. We will just use hardcoded header text. So, each variation will be inserted with the harded header text instead of the one from settings, and user can always edit it as per the requirement once block is added.

@iamdharmesh iamdharmesh changed the title [WIP] Add Form templates [Block] Add Form templates Jul 18, 2025
@iamdharmesh iamdharmesh marked this pull request as ready for review July 18, 2025 06:05
@iamdharmesh iamdharmesh requested a review from dkotter July 18, 2025 06:05
@github-actions github-actions bot added the needs:code-review This requires code review. label Jul 18, 2025
@qasumitbagthariya
Copy link
Collaborator

QA Update: Question ⚠️

@iamdharmesh

When we select any template, the fields remain the same. For example, even when choosing "Quick Signup (Email only)", it still shows the full form. Similarly, for "Personal Signup (Name, Email)", it also displays the full form. The question here is whether the form should change according to the selected template or not.

Screen.Recording.2025-07-22.at.6.53.21.PM.mov

cc @dkotter

@iamdharmesh
Copy link
Collaborator Author

Thanks for testing this, @qasumitbagthariya.

The question here is whether the form should change according to the selected template or not.

Yes, it should change according to the selected template. However, I noticed in the video that the extra fields being shown are marked as required, that's why they are appearing. Thanks for raising this.

As per our current setup, required fields are always visible, and we don’t allow hiding them via the block visibility settings (same at the global level). Also, if we don’t pass the required field information while submitting the form, the Mailchimp API responds with a required field error. However, we can bypass the required validation by passing skip_merge_validation=true.

Given that form templates are meant to display only specific fields, we may need to change the current visibility behavior to show only the fields defined in the selected template and skip merge validation accordingly. @dkotter, I’ll make these changes, but just wanted to check if you have a different take on this. Thanks!

@dkotter
Copy link
Collaborator

dkotter commented Jul 22, 2025

Given that form templates are meant to display only specific fields, we may need to change the current visibility behavior to show only the fields defined in the selected template and skip merge validation accordingly. @dkotter, I’ll make these changes, but just wanted to check if you have a different take on this. Thanks!

I think that all makes sense and is probably the ideal way to go. Would it be easy enough to show a message somewhere in those scenarios, alerting the user to the fact that the form template they chose doesn't have some of the fields required by Mailchimp and thus merge validation will be turned off?

@iamdharmesh
Copy link
Collaborator Author

Would it be easy enough to show a message somewhere in those scenarios, alerting the user to the fact that the form template they chose doesn't have some of the fields required by Mailchimp and thus merge validation will be turned off?

Yes, will show the warning message as well for this. Thanks

@iamdharmesh
Copy link
Collaborator Author

@dkotter @qasumitbagthariya This is ready for review now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:code-review This requires code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Block] Add Form templates
3 participants