Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Netlify form submissions are blank

Tags:

netlify

When I submit my Netlify form the server responds with a 200 status and I get the 'thank you' response page. However, when I check the form submission in the Netlify admin, they are all blank. I've inspected my xhr requests and the data shows in the 'params' section of the browser dev tools.

params dev tools enter image description here

like image 880
dlaub3 Avatar asked Apr 15 '18 21:04

dlaub3


3 Answers

Disclaimer: I work for Netlify.

When our service stores blank submissions, it has not received any fields from the submission which were defined in the html version of the form with the same name parameter in its definition as the submission.

To start off with, it's useful to know that our service requires a plain html version of your form, with a name parameter as well as the netlify or data-netlify=true parameter; this is what prepares your site to accept form submissions at all, so you had that set up right already; if you didn't, you'd get a 404 when POSTing.

Once you have this in a deploy and we parse it correctly, you'll see the form name in your site settings dashboard on the 'Forms' tab. Note that we ALSO pull all the field names we'll save and show to you in notifications or the dashboard from this file and only this file, so make sure you give each form field all a name as well, in that html file.

If you see the form in your dashboard, yet get a blank submission when you are sure data was POSTed, this probably has one of three causes:

  1. Netlify did not correctly process your field names from the html version of your form. The service will only properly handle the fields which we see in that html version at deploy time.
  2. Netlify does matching by field name at submission time, so make sure that what your site sends to us then matches up between with your deployed html copy of the form. This happens automatically for pure html (no JS) forms since you are POSTing from the file which is the canonical "definition" of your form fields; however for javascript forms you need to take care that the names match up. Put another way, you cannot later add new fields dynamically in javascript and send them (Netlify will accept all fields, as you have seen; but will not store them or notify you about ones that were not processed at deploy time!)
  3. One more quirk that could get in the way: having multiple copies of a form with the same name in your deploy. Only one will be processed, so if you happen to have an errant <form name=test netlify></form> in another html file (or even the same one!) - it could be the one that we process rather than the other form also named test. So, make sure that you only send a single html definition of your form. Note that some frameworks like gatsby render your jsx down into html before deploy, meaning that if you have a plain html file form definition in your deploy - it could be processed instead of the copy gatsby built.

This blog post describes a successful form built in a react app: https://www.netlify.com/blog/2017/07/20/how-to-integrate-netlifys-form-handling-in-a-react-app/

like image 184
fool Avatar answered Oct 19 '22 22:10

fool


I missed the "name" attribute in input field.
Every input in the form must have a "name" attribute. Something like <input name="email" ...> or <textarea name="message" ...> is what you need.

like image 27
GorvGoyl Avatar answered Oct 19 '22 23:10

GorvGoyl


Don't miss the "name" attribute for both parent and child layers

<form name="contact" method="POST" data-netlify="true">
  <input type="text" placeholder="name" class="box" name="name">
  <input type="email" placeholder="email" class="box" name="email">
  <input type="text" placeholder="project" class="box" name="project">
  <textarea name="message" id="" cols="30" rows="10" class="box message" placeholder="message"></textarea>
  <div class="field">
    <div data-netlify-recaptcha="true"></div>
  </div>
  <button type="submit" class="btn"> send <i class="fas fa-paper-plane"></i> </button>
</form>
like image 28
Brynold Avatar answered Oct 20 '22 00:10

Brynold