Hey guys, I’m using a simple GatsbyJs component to render a simple form with Netlify…
As soon as my page loads…one of my input fields is being removed and I have no idea why…
The field being removed is an input type URL field…so people can send me a YouTube link…I tried switching it to a input type TEXT but still…it is removed automatically…it shows for 1 second then disappears…
I also had a bot-field in there…but I removed it just to make sure it’s not interfering…the form works…I get the name and email…but the url is being removed…
Seems likely you have 2 definitions of your form in html (or that is the javascript version of the form, and the html version is different). We parse the form at build time, from HTML ONLY, and if there are two copies, only one will win. If you update only the JS, the HTML will still be our source of truth.
This article talks about how to debug form misbehavior and I’d bet my next paycheck that the answer is in there
Me neither, without more information. I’d expect that it is what I said - the first update was to some javascript that maybe gets rendered to html by your SSG and it maybe missed that field? Anyway, glad to hear you have a solution for now
Thanks again! I actually found the solution and I’m sharing for others to find in the future!
If you are using JavaScript to render your forms…I.E you’re not using pure HTML…but instead you have a component that renders HTML…as in REACT, GATSBY, VUE and so on…
You need to manually add a hidden input field as the first item in your form…like this
Don’t forget to make sure the value matches the name of the form as well!
Basically when using pure HTML…Netlify adds this field automatically to your form…but when using any kind of JavaScript library or framework…you need to add it manually!