Well that “something” that changes between dev and prod deployment is obviously key, as apparently it’s not crystal clear, not even from the documentation, as to what exact conditions are required for a form to appropriately take submissions.
I mimiced almost 100% what has been posted in the ‘Form Handling with a Stateless React Form’ section of How to Integrate Netlify’s Form Handling in a React App only to realize that having the form tag with an onSubmit
attribute only would clearly (this is tested!) NOT work.
I mean I’m happy I got it working, and also accept you cannot put effort (and therefore money) into a feature (clearer form submission confirmation in dev) that’s not requested by many, but maybe the doc could be a bit more straightfoward about what exactly is, or is not absolutely required for the submission to work, ie what the build process looks for in the form in the html file, and what exact http body content is the server looking for in order to accept it as a submission.
We have listed the conditions here (and more info): [Support Guide] Form problems, form debugging, 404 when submitting - Support / Support Guides - Netlify Support Forums
A POST request with a field named form-name
and value as the name of the form you’ve configured.
What confused me a lot is How to Integrate Netlify’s Form Handling in a React App, if there is a way to correct that, it would be great.
Thanks for all your help and assistance.
Could you mention what’s the confusing part OR what exactly needs to be corrected? I don’t think that guide is necessarily wrong. It probably doesn’t include the details I provided in my last response, but the guide is still true in itself.
As I already mentioned in my previous reply, the article’s ‘Form Handling with a Stateful React Form’ section incorrectly shows a code bit where the form
tag has missing required attributes, like a name
or the netlify
attribute, without which the form results would not appear in the Netlify UI (I recently tested this).
Both, name and netlify attributes are indeed not required in React forms, because React will not generate static HTML. It will instead render the form using JavaScript. They’re only required for in the HTML that’s available during the deploy time so that we detect it and enable the functionality.
So in case of React, you need not add those attributes on the form in your JSX, but you’d have to add those in the static HTML version of your form.
That’s the confusing bit, because the article shows that part as the full code you need, but instead you’d need more, ie. the HTML bit of your form separately, so in itself, it’s not a complete solution.
Anyways, I don’t intend to go on about this, it is what it is, we don’t fully agree, I still believe the ability to actually be confirmed about if the form submission would work would be nice in dev, and that article could be written better.
There is nothing more I can say about this.
Thank you for all your help!
Thanks for sharing. I’ll pass it on to the team, though blog posts are usually “make and forget” types as opposed to the official docs and Support Guides which we keep updating. We do update blog posts in certain situations, but that’s a call the relevant team needs to make.