Empty form submissions due to "action"

Hello
I am sending test emails to myself using my form and they all come empty.

My website is currently in two languages.
I tried to create a custom confirmation page but when I add an action, the submissions come empty.
Here is my code:

<form class="b-contact-page__form" data-netlify="true" method="POST" name="contact" action='{{ T "confirm" }}'>

          <label class="b-contact-page__label" for="name">{{ .form_settings.name }}:</label>

          <div class="b-contact-page__input">

            <input name="name" type="text" id="name" required placeholder="{{ .form_settings.name_placeholder }}">

          </div>

          <label class="b-contact-page__label" for="email">{{ .form_settings.email }}:</label>

          <div class="b-contact-page__input">

            <input name="email" type="email" id="email" placeholder="{{ .form_settings.email_placeholder }}" required>

          </div>

          <label class="b-contact-page__label" for="message">{{ .form_settings.message }}:</label>

          <div class="b-contact-page__input">

            <textarea name="message" id="message" rows="6" required placeholder="{{ .form_settings.message_placeholder }}"></textarea>

          </div>

          <div class="b-contact-page__submit">

            <button type="submit">{{ .form_settings.button_text }}</button>

          </div>

        </form>

Hiya, sorry you are having trouble getting your forms to work.

This Support Guide is the first port of call to debug any forms issues. There are also many other Support Guides for forms - you can find them here: #Netlify-support:support-guides

We also recommend trying to search the forums or look at topics tagged Netlify forms if you haven’t already - it’s likely your question was already asked by someone else!

If you are still having problems, please provide more information such as what you have already tried, and a link to your live form. :slight_smile:

here is the live form:

Netlify documentation says I need to add ‘action=“/thank-you”’ to redirect a user to my custom confirmation page after sending a message using their forms. I do so, and it sends me to the page correctly, but all of the messages come blank even though I know I filled in everything. I removed the action, and it started showing again.

I really can’t find anywhere else someone who has had this problem. I have been looking for one for two days

Hey @Paloma,
The action="/thank-you" is example code that assumes your custom confirmation page is called “thank-you.html”- sorry for the misunderstanding there. If you have a confirmation page with a different name, that’s what should be in the action path, like action="/success" etc. Let us know if that helps!

No, that’s not what I mean. I have the “thank-you.html” page created. It works, I send a message and it sends me to the page correctly as I mentioned. The problem is that when I add it, all messages I receive in my inbox come blank, no email, name, or message. Once I remove it and re-try, the messages don’t come in blank anymore.

paloma, can you post your form code for us please?

yes here it is. thank you for helping

<form class="b-contact-page__form" data-netlify="true" method="POST" name="contact" action="/thank-you">

          <label class="b-contact-page__label" for="name">{{ .form_settings.name }}:</label>

          <div class="b-contact-page__input">

            <input name="name" type="text" id="name" required placeholder="{{ .form_settings.name_placeholder }}">

          </div>

          <label class="b-contact-page__label" for="email">{{ .form_settings.email }}:</label>

          <div class="b-contact-page__input">

            <input name="email" type="email" id="email" placeholder="{{ .form_settings.email_placeholder }}" required>

          </div>

          <label class="b-contact-page__label" for="message">{{ .form_settings.message }}:</label>

          <div class="b-contact-page__input">

            <textarea name="message" id="message" rows="6" required placeholder="{{ .form_settings.message_placeholder }}"></textarea>

          </div>

          <div class="b-contact-page__submit">

            <button type="submit">{{ .form_settings.button_text }}</button>

          </div>

        </form>

Hey @Paloma,
Thanks for clarifying and sharing your form code. It’s possible that the special characters in your action field are breaking our form parser- is it possible for you to hard code the path to the custom thank you/success page instead of using action='{{ T "confirm" }}'?

Well I was using that because my website is in two languages. However I did try without it, as in just the thank-you page, and I was still having the same problem. It is very strange because I can’t find anywhere in these forums someone who has had the same problem

hi paloma, were you able to make any progress on this?

No, nothing… I think it must be a netlify bug

Hey @Paloma :wave:t2:

So this form is still having problems? You’re currently not receiving any submissions from it? I tend to have some luck with Forms and would love to help out. Just wanted to check in first.

Did you remove the action= attribute from the <form> tag in your source code? It doesn’t seem to be making it through the build process (which may be what @jen was meaning — the form parser that runs during the build errors on parsing that field and removed it altogether)

I’m not sure which SSG you’re using, and making a bit of a guess here just assuming you’re using some form of Liquid templating engine, but could you try changing your source code from action='{{ T "confirm" }}' to action="{{ T 'confirm' }}" ? The difference I made there is in swapping the single and double quotes. HTML specifications require that any HTML attribute’s value (that isn’t an unquoted literal) requires the use of double quotes, not single. Your T function should operate no differently with a single-quote argument as well. Can you give that a shot and see if it works?

–
Jon

Thank you for helping.
I will answer your questions:

You’re currently not receiving any submissions from it?

I receive the submissions, the problem is that they come in blank

Did you remove the action= attribute from the <form> tag in your source code?

In the live website, I removed the action attribute altogether for now in case I receive any emails I don’t want them to be blank.

could you try changing your source code from action='{{ T "confirm" }}' to action="{{ T 'confirm' }}" ?

While I was testing, I tried both action="/thank-you" and action=’{{ T “confirm” }}’, and neither worked, the emails came in blank both times. If action="/thank-you" worked then I’d think the problem would be action=’{{ T “confirm” }}’, but that wasn’t the case…
I’m using Hugo and Forestry for the site.
I tried what you said anyway just in case and the deploy failed, I can’t change it to action="{{ T ‘confirm’ }}"

Interesting that the deploy failed. Let me go ahead and submit a test submission or two and see how the request/response cycle looks from Netlify.

Yes, this was the deploy error:
Error: “/opt/build/repo/layouts/contact/single.html:13:1”: parse failed: template: contact/single.html:13: malformed character constant: ‘confirm’

Interesting. Your form appears to be in good shape and both test submissions appeared to be received just fine. Regardless of whether or not the action= attribute is working, I’m not seeing anything really wrong with your form source, resulting markup, or the penultimate POST request made to Netlify. Did either of my submissions come through with data?

–
Jon

It worked but that’s because I don’t have the attribute applied right now. I don’t want to risk receiving any blank messages that could be important. If you want, maybe you can tell me what time (and at what time zone) you can test it, and I will make sure to add the attribute 5 minutes before that time. Would that be alright?

Gotcha, I see. That makes sense. Actually could you just run one more test yourself? I’d previously recommended adjusting your markup to action="{{ T 'confirm' }}" but could you actually try

action="{{ T "confirm" }}"

Your editor may highlight it incorrectly (like above) or a linter may parse it with an error, but technically speaking, that should be correct. Liquid parses a file as plain text and replaces what’s inside of {{ and }} - it shouldn’t care about the rest. I think that ought to correctly result in an output of action="/thank-you" (or whatever your T function returns)

Let me know if that works :slight_smile:

–
Jon

Hello,
The deploy works but the code doesn’t work at all with action="{{ T “confirm” }}".
When I had action=’{{ T “confirm” }}’ it took me to the thank you page but the message came in blank.
With action="{{ T “confirm” }}" it won’t take me to the custom thank you page at all.
I really don’t think the problem is in the markup of the action attribute. I have no idea what it could be instead, though…

Hey @Paloma,
The issue is almost certainly the action attribute. We currently don’t support having a variable in the action field- only a static path. I’ve filed a feature request for this and we can let you know if/when we implement it.

If your framework supports client-side routing (like Gatsby’s navigate), a workaround would be to route to the correct thank you page after the form submission, and ditch the form action field altogether. Sorry we don’t have better news for you today!

1 Like