DEV Community

Brian Morrison II
Brian Morrison II

Posted on • Originally published at brianmorrison.me

Lessons Learned With Netlify Forms

I decided to throw this together since I've been working on testing & debugging Netlify forms over the weekend. Some of the issues I ran into we're somewhat obvious in hindsight, but here is quick list of what I learned while building a reusable Vue component (to be open sourced in the near future). I'm not going to make this a long, drawn out article, just a few bullet points.

  • If you have a <label> for your input, it will use that when displaying the fields in Netlify, like so;

https://cdn.brianmorrison.me/media/2020/27ecb42a-e22a-4ec4-8d11-608720a86401

And here's the code.

    <div class="form-group">
      <label for="name">Your Name<span class="required">*</span></label>
      <input type="text" class="form-control" name="name" id="name" v-model="formData.name" placeholder="Jane Smith" required>
    </div>
Enter fullscreen mode Exit fullscreen mode
  • It's important that the name in the input attribute matches the key of the actual data being submitted.
  • Fun fact, you can actually test form submissions to Netlify with Postman like so;

https://cdn.brianmorrison.me/media/2020/4b858ad1-7620-4e88-98b9-9b15756e392b

  • When testing with Postman, the form-name form key must be present and match the name of the form. That seems to be what tells Netlify how to match up the incoming data. If its missing, you'll get a 404.
  • Since you can simply POST the data to the URL, this means that you can actually test submissions locally with JavaScript by swapping out '/' with whatever the domain or subdomain of your Netlify app is like so;

https://cdn.brianmorrison.me/media/2020/a0e20893-0f80-48bc-a66a-d139c0eb9f83

Hope this helps someone. Happy coding!

Top comments (0)