Netlify form submissions are blank - 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.

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:
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.
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!)
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/

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.

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>

Related

how to access form input elements in get request for node

In my html in a node application I have a form as follows:
<form action="/getRoute" method="get">
<input type="hidden" name='a' value=<%- array1[0].element1 %>>
<input type="hidden" name='b' value=<%- array2[0].element2 %>>
<button type="submit">Submit</button>
</form>
When I click submit, the getRoute route is executed successfully (confirmed by console.log statement) - however, I cannot access the values of the hidden input fields by req.body - would anyone know how I can access these, or alternatively use another html element to pass data into the route?
Just found out that you these inputs are passed via the URL and can be accessed by req.query.a and req.query.b - it's not ideal to send sensitive data via get requests since the URL can be seen.

Get Attachment from POST using Agent and LotusScript

I have a web form (see dummy example below), it's printed by an agent.
When form is submitted it's processed by an agent (LS).
I do not know how to retrieve files/attachments, that is my problem.
<form name="profile" method="POST" action=".../postAgentName?openagent">
<input name="title"/>
<input name="price"/>
...
<input type="file" name="files" multiple>
</form>
Attachments are not part of DocumentContext as far as I see but only file-names. I kind of suspect files could be temporary uploaded to Domino within request somewhere but really I'm not sure?
Is it possible to get attachments using LotusScript from "files" controller within agent written in LS?
Can somebody point me in right direction? or maybe give a tip what should I do?
Thanks a lot.
I have built my own solution
when we select files on client side - we convert them to base64 with javascript
<form name="formName" method="post" action="agentName?openagent">
<input name="title" value="xxx">
<input type="file" name="files" multiple onchange="toBase64()">
</form>
we add base64 strings to form just like normal so they will be submitted to endpoint (agent)
var reader = new FileReader();
agent will get base64 value and convert it back to file (using LS or Java/LS2J)
Call stream.WriteText(base64File)
Call item.SetContentFromText(stream, contentType, ENC_BASE64)
See details here (could not format properly here):
https://dpastov.blogspot.com/2021/01/how-to-post-attachments-using-form-to.html
To accept files as part of form submission, you have to set the form 'enctype' attribute to handle files:
<form method="post" enctype="multipart/form-data" action="/x.nsf/x?CreateDocument" name="_fmForm">
Files attached using 'file upload control' (FUC) in Domino will be attached to the document and are accessible via attachment type embedded objects as part of the web-query-save event.
(Note: Generating your own form with a file-upload to Domino is tricky).

asp-for does not generate code on Razor Page

I must be missing a configuration setting.
Simple example:
<input asp-for="Login.UserIDMaybe" type="text" class="inputStandard" placeholder="User ID" autofocus>
When the page compiles, the result is that exact same HTML, and when the form is submitted, the UserIDMaybe property of the model is always null.
To test that everything else is cool, I can replace that input HTML with the following, and it works (the Login.UserIDMaybe value is filled with what the user entered into the Input).
<input for="Login.UserIDMaybe" type="text" class="inputStandard" placeholder="User ID" autofocus>
Maybe I have completely misunderstood the usage of asp-for, or maybe I have failed to "turn it on". Thanks.
And yes "#addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers" is in the _ViewImports.cshtml file, but maybe that is not enough.
If you are using MVC and Razor Pages, make sure you have a _ViewImports.cshtml in your Pages folder too.

Node.js Getting values from html and using req.body.<name>

I am trying to retrieve multiple values from HTML and make use of it using req.body..
I am able to do this via message: req.body.message
<form id="message-form" class="input-group input-group-lg" style="">
<input type="text" name="message" class="form-control" aria-label="Large" aria-describedby="inputGroup-sizing-sm">
<div class="input-group-prepend">
<button class="btn btn-primary">Send</button>
</div>
</form>
However, I would like to retrieve the values from elements that are not inside the e.g <span id="item" style="font-weight:bold"> </span>
The reason is that when I load the page, it renders these values dynamically (retrieved from database). When I want to do a POST, I would like to make use of these values that have been rendered previously.
Is there a way to do this?
Many thanks.
Forms don't submit data that does not appear inside a form control.
So you can either:
Store the data somewhere in the server (such as in a session) where you can read it back on a subsequent request (watch out for race conditions!) or
Put the data in a form control instead of or as well as in the span. (Possibly using a hidden input).

generate html with translation

For a generic form checker I want to generate html <input> fields plus internationalized error messages (and default values, ...) while using templates to define which fields are in the form.
Template example:
...
<form>
${structure: make_field('email')}
</form>
Rendered template:
...
<form>
<input type="text" name="email" ... /><span>error message</span>
</form>
Problem:
The error message for each field is specified using gettext like _('error123'). Because the html string is constructed by code I have to translate() the error message myself. Therefore I have to hand in a localizer to the form checker code which I want to avoid.
Is it possible to move the rendering completely to the template engine. Maybe with macros generated in code?!

Resources