Handling form errors on a page with multiple contact forms

Topic summary

Multiple contact forms on a single Shopify page are showing validation errors across all forms, not just the one submitted. Each form uses a custom id, but the Liquid form object (form.errors) appears shared, causing cross-display of errors.

Key suggestions:

  • Ensure unique form IDs by namespacing with the section.id (e.g., assign form_id = section.settings.form_id | append: ‘-’ | append: section.id; then use id: form_id). This mirrors the Dawn theme’s approach.
  • Note that form_errors likely doesn’t include an identifier to map errors to a specific form. Consider tracking which form was submitted (e.g., via return_to or a cart attribute) to conditionally show errors only on the active form.
  • Prefer dot notation over square brackets for Liquid settings access when possible.

New issues raised:

  • Form data is not persisting in fields after submit; values only appear in the URL query string.
  • “Invalid email” error occurs despite valid input. Another user reports the error appearing on a different form (footer newsletter) instead of the intended contact form, suggesting conflicts between multiple forms.

Status: No confirmed fix yet. Guidance provided on unique IDs and state tracking; email validation and persistence issues remain unresolved.

Summarized with AI on January 25. AI used: gpt-5.

Good evening Shopifyer’s

I have one page with 3 contact forms, all with unique IDs set like so:

{% form 'contact', id: section.settings['form-id'] %}

I am having issues getting the form errors because each form is displaying the form errors because the form object is being picked up.

{%- if form.errors -%}

That is present between each form tag and so is showing up in all the forms.

Is there a way to differentiate between the form errors being received like checking what form ID they have/relate to?

Any pointers to get that working?

Many thanks

Evening, this line gives all forms the same exact same ID attribute value, unless they are all unique sections with unique settings.

{% form 'contact', id: section.settings['form-id'] %}

Generally it should be

{%- assign form_id = section.settings['form-id'] | append: '-' | append: section.id -%}
{% form 'contact', id: form_id  %}

How dawn’s handles product form name-spacing

https://github.com/Shopify/dawn/blob/main/sections/main-product.liquid#L69

Beyond that I don’t think form_errors return any identifying reference information about a form

https://shopify.dev/docs/api/liquid/objects/form_errors , just spit out the object and see if it does.

You may just need to track the state of which form was submitted to associate the errors to the proper form. Spitball - for javascriptless maybe see if you can set a cart-attribute using return_to redirects to indicate the “active” form in liquid.

When dot notation would work fine to get a value avoid using square bracket notation.

SBN generally indicates something is being hardcoded like a handle , or the value passed to SBN will be dynamic.

{% form ‘contact’, id: section.settings.form_id %}

Thanks for your time on this Paul.

Actually using the SBN in this line was only being used on one contact form.

{% form 'contact', id: section.settings['form-id'] %}

So I am using this on all the contact forms.

{% form 'contact', id: section.settings.form-id %}

I’m also having issues with the form not persisting the data. It shows up in the URL bar though.

But more specifically, I am constantly getting an invalid email error on this form and not sure why. The email is correct when I enter it. If you can help on this one big thanks!


Hi Sam.

I am having a similar error with my form “I am constantly getting an invalid email error on this form and not sure why. The email is correct when I enter it.”

In my case, I have a new contact form and when submit it I get an email error in the newsletter subscription at the footer, not in the one I have as a field in the contact form.

Were you able to solved your issue? Maybe I can try with a similar solution.

Thanks in advance!

Roger