Bug Report: Forms, names, and actions

I ran into this today by accident. I have a site that has a form (form.html) with the name, “Contact Form”, and the action /thankyou.html. I made a new form (form1.html) and did NOT specify an action. On submit, it still goes to /thankyou.html. The URL doesn’t show this, it shows /form1.html, but the contents are thankyou.html. That’s bug one.

Now for the weird part. I figured out the issue must be the form name. Netlify saw the earlier submission of form.html with the same name and just assumed, “All forms with this name go to /thankyou.html.” However, in form1.html, I specified a new action, /rc.html. I definitely typed out the full path. On submit, it still renders thankyou.html, but the URL says /rc.

The fix is to obviously have unique names, but I’d argue that if I have a specific action, I should end up there.

Thanks for the report, Raymond! This is not what you wanted to hear, but our system is operating as intended here. Unique form names are REQUIRED for multiple forms, end of story. Or to state it a different way: we don’t care as much about action= as we do about what you have the field form-name set to - THAT is how we distinguish which form to attribute the POST to, and we parse all forms with the same name down to a single definition.

That’s fine really - just a bit weird at first. But - can this be added to the documentation please?

Howdy! We think it does already, but can you confirm this is interpretable for your use case?

Your form’s name attribute determines what we call the form in the Netlify app interface. If you have more than one form on a site, each form should have a different name attribute.

I want to make sure we are being as clear as we can be, here! If you are misunderstanding this, its likely others are too. Thanks for your help!

I don’t think so. I mean, it makes sense, but it should be clear that once you submit a form with name X, you have “locked” down the logic of X forever. Let’s say I build a new form, and I think it makes sense to call it X. If I delete the old file, make a new file, but use the same name, I expect it will act the same, ignoring my new action. I’m still “following the rule”, having unique names for forms. Or will Netlify recognize on each build and therefore pick up the fact that I deleted the old file? See why I’m confused? :slight_smile: If it’s per build than I think we’re good.

that’s good feedback! I’ll make sure it gets passed on :+1:

Wait, so was I right? That if I delete a file using name X and make a new file using name X, that on the next build, it will use the action value of the new file?

I’m not sure yet! I am going to reach out to our docs team to clarify what the intended behaviour should be and if we need to change our docs. I’ll update here once i know more.

Gotcha - thank you for digging into this!

Hi @cfjedimaster, just wanted to confirm some details. When you removed the action attribute from that second form, did you still have the first form deployed on your site? If so, our system will see that as the same form and only check the first one it encounters. So, as you discovered, if the form is not identical (everything from fields to actions), give it a new name.

That said, if you didn’t have another form with the same name but different action (e.g. you replaced the old form with the new one) and the form was not updated, let me know. As that would be a bug. :slight_smile:

Yep, the first one was still there.