solspace / craft-freeform

Freeform for Craft: The most reliable form builder that's ready for wherever your project takes you.
https://docs.solspace.com/craft/freeform/v5/
Other
47 stars 61 forks source link

Forms don't have correct Formatting after validation #1607

Closed valboivin closed 1 week ago

valboivin commented 2 weeks ago

What happened?

If we have multiple forms on a same page, the first one will always be ok. However, the subsequent ones won't have the same correct formatting once we try to submit them. The default templating we use for our forms is "Bootstrap 5". This is also the same one we use for every form we have created on our website.

For example, if we try to send a form with empty required fields, we expect the class is-invalid to be added to the incorrect fields. Right now, it is the case only on the first form, but not on the other ones (which are all setup the same way and using the same rendering twig template). It is not the only problematic class. It looks like the validated form looses its Bootstrap formatting overrides.

We've tried to fix this by overriding the render method to manually add the error class to no avail. Something odd is that if we look into the Network tab, the response object has the expected classes in its html property.

We've been using Freeform for a couple of years already, and we didn't have problem with the default framework formatting before. We've tested with the different versions, and those before 5.6.0 don't have this bug. It seems like something has changed in the 5.6.0 version.

Errors and Stack Trace (if available)

No response

How can we reproduce this?

  1. Add multiple forms with the Bootstrap 5 templating on the same page
  2. Try to submit the forms with invalid/empty fields
  3. The first form will have the is-invalid class on its invalid fields and the other forms will have the freeform-has-errors class on its invalid fields.

Freeform Edition

Pro

Freeform Version

5.6.4

Craft Version

5.4.9

When did this issue start?

After upgrading from older Freeform version

Previous Freeform Version

5.5.10

kjmartens commented 1 week ago

I'm sorry for the delay and the trouble you're experiencing @valboivin,

I'll have a developer check into this and get back to you shortly. 🙂

kjmartens commented 1 week ago

This should now be resolved in Freeform 5.7.2+ 🙂