Netlify does not recognize form in nuxt app - forms

We implemented a simple nuxt app with a basic form and deployed it to netlify.
When pressing the "Submit" Button of the Form, we receive a 404.
Here you can find the link to the deployed netlify app:
EDIT -> Removed Link
After looking through the troubleshoot guide, they listed that the added "netlify" or "data-netlify="true" attributes should not be visible if netlify recognized your form, but they are.
Plus the form can't be found in the "form" configuration tab of the netlify backend.
Nuxt config:
SPA
Tailwind
We tried to add the necessary attributes for netlify:
netlify or
data-netlify="true" & netlify-honeypot="bot-field"
We also added a "pre-render" library called prerender-spa-plugin.
Here you can find the contact.vue page content.
Simple form with "name" attributes set according to netlify documentation.
<template>
<div>
<form name="contact" method="POST" data-netlify="true" netlify-honeypot="bot-field">
<p class="hidden">
<label
>Don’t fill this out if you're human: <input name="bot-field"
/></label>
</p>
<p>
<label
>Name
<input
type="text"
name="name"
class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 mb-3 leading-tight focus:outline-none focus:bg-white;"
/></label>
</p>
<p>
<label
>Email
<input
type="email"
name="email"
class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 mb-3 leading-tight focus:outline-none focus:bg-white;"
/></label>
</p>
<p>
<button
type="submit"
name="submit"
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
>
Send
</button>
</p>
</form>
</div>
</template>
<script>
export default {};
</script>
<style>
.hidden {
display: none;
}
</style>
It would be great if we can manage to fix this, so that netlify finally recognizes our form.

Netlify comes with built-in form handling. Our build bots do it by parsing your HTML files directly at deploy time, so there’s no need for you to make an API call or include extra JavaScript on your site.
The form is required to be in the rendered files at deploy time. The problem with SPA mode is that none of your pages are actually rendered as HTML. You can check this by right clicking the page, and clicking "View Page Source". You won't be able to find the form.
Netlify addresses this problem here in their docs.
They have a specific post for fixing this for a Vue app here
A little more digging on the the issue and we find a Nuxt solution here:
Place the following in static/form-dummy/index.html:
<form name="MYFORM" action="/form/success" netlify>
<!-- form controls here -->
</form>
Place the following in pages/form/index.vue (Or whenever you've named your Vue file)
<form name="MYFORM" action="/form/success" method="post">
<input type="hidden" name="form-name" value="MYFORM" />
<!-- form controls here -->
</form>
From the post:
You just need to make sure you add that hidden in the Vue component so that Netlify recognises the form submission as associated with the form called MYFORM. I think you also need to ensure all the inputs you want to receive data for are on both forms.

Related

Unable to receive form submissions on Netlify deploys

I am using a simple form that was taken from one of the Netlify related docs:
<form name="contact" action="/" method="post" data-netlify="true">
<div className="field">
<label htmlFor="name">Name</label>
<input type="text" name="name" id="name" value="dave"/>
</div>
<div className="field">
<label htmlFor="email">Email</label>
<input type="text" name="email" id="email" value="email#email.com" />
</div>
<div className="field">
<label htmlFor="message">Message</label>
<textarea name="message" id="message" rows="6"></textarea>
</div>
<input type="submit" value="Send Message" className="" />
</form>
In using gatsby develop and working with/submitting the form, things seem to work fine. I get no errors and get redirected to the home page as expected.
After deploying the site with Netlify and trying to submit the form, I get the following page error:
In my Netlify backend, the form appears in the console but I cannot/do not receive submissions.
I am using a barebones gatsby-config.js, only incorporating gatsby-source-wordpress and gatsby-plugin-google-analytics.
I also tried adding /no-cache=1 to form action.
Can anybody advise?
It might also be worth noting that I have coded my form as a component and am importing it into my footer as such. In that way, it may be imported multiple times on different pages as mentioned in point 3 of this StackOverflow answer.
Thanks.
I learned that because I'm using Gatsbyjs, and Gatsby + Netlify = javascript forms, I needed to add another input type="hidden" to my form:
<form name="my-form" ... >
<input type="hidden" name="form-name" value="my-form" />
The documentation for this wasn't immediately clear but below are some links that address this:
Here's a link to an article that pointed me to the answer: How to
Integrate Netlify’s Form Handling in a React App
Here's another one if you're building in Vue: How to Integrate
Netlify Forms in a Vue App
And all about Netlify Forms
If you are using any redirect method then you have to add _redirects file in your root folder and add paths to it so that redirect can work.
It's may be confusing but you can visit this link for more help.

Ionic 3 form still warning me: "Password field is not contained in a form"

I'm new to the Ionic framework, and I'm using Ionic 3.
Even though I use a form in my app, I'm still getting this warning in the browser:
[DOM] Password field is not contained in a form:
Why is that, and how can I fix it?
What is it?*
Chromium project (mostly Google Chrome) wants to change the world and make all passwords, as well as all form data autosaved and autofilled by default. The people behind this decision claim that will make the web safer†. While Firefox also promotes autosaved and autofilled form data, Chrome goes further admonishing web developers to comply with form element scoping that's more convenient for the browser.
At the same time, Google Chrome uses heuristics to determine what a "form" is on the web page and doesn't actually need individual form elements to be wrapped in a <form> element.
Additionally, Google Chrome treats all web pages, all forms and all form fields as if they are filled by the end user, where password is user's own password. A use-case where e.g. company administrator fills in new joiner's initial password is not supported.
The shortened URL in the form takes you to Create Amazing Password Forms page the the Chromium projects. Today the text there is very patronising, thus I'll omit the link.
†I neither claim to agree with Chrome/Chromium, nor claim that Google is in the position to profit from autofill via lock-in or access to user data; that's out of scope.
How can I fix it?
Simple: ignore it.
It's only a notice in developer tools in one of the major browsers.
Solution 1:
I think you are using Chrome browser. If you will try on Mozilla, it will not give the error. Please refer to this link for more details:
https://github.com/aws-amplify/amplify-js/issues/165
Here is the example:
<div className="myform" onSubmit={this.validateLogin()}>
<div className="myformgroup">
<label>Email</label>
<input type="text" placeholder="Email" id="email"></input>
</div>
<div className="myformgroup">
<label>Password</label>
<input type="password" placeholder="Enter the Password" id="mypassword" value=""/>
</div>
<div className="myformgroup">
<button type="submit" id="loginButton">Login</button>
</div>
</div>
Is returning the password field is not contained in a form.
Solution 1:
After changing the master div tag to a form as I have in the following:
<form className="myform" onSubmit={this.validateLogin()}>
<div className="myformgroup">
<label>Email</label>
<input type="text" placeholder="Email" id="email"></input>
</div>
<div className="myformgroup">
<label>Password</label>
<input type="password" placeholder="Enter the Password" id="mypassword" value=""/>
</div>
<div className="myformgroup">
<button type="submit" id="loginButton">Login</button>
</div>
</form>
it will not return the warning.
Solution 2:
Install aws-amplify in your project directory as explained in https://github.com/aws-amplify/amplify-js.

how to use a Hubspot form embed code with a bootstrap form

I have a client that uses hubspot for their tracking and thank you pages. I have created a landing page using bootstrap and within the page I have two forms. Both forms are the same and I want them to go to the same thank you page. The client has provided me with an embedd code but I am not sure how I can bridge the gap. Below I have listed my form code and the embed code. I basically want the user fields to be submitted into hubspot and for it to trigger the thank you page but I am not entirely sure this is possible. Any help would be appreciated.
<div class="col-lg-12 contact-form">
<div class="container">
<div class="formContainer">
<form role="form">
<div class="form-group">
<div class="col-sm-6 left-field">
<input type="text" class="bottom-form" id="firstname" placeholder="First Name">
</div>
<div class="col-sm-6 right-field">
<input type="text" class="bottom-form right-field" id="lastname" placeholder="Last Name">
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<input type="email" class="bottom-form email" id="email" placeholder="email">
</div>
<div class="col-sm-12">
<button type="submit" class="submit bottom-submit">Download Now</button>
</div>
</div>
</form>
</div>
</div>
</div>
Here is the hubspot embedd code.
<!--[if lte IE 8]>
hbspt.forms.create({
css: '',
portalId: '2030148',
formId: 'd9005302-a859-4a39-9d47-74d8a1d25fb0'
});
Are you just looking to set the redirect with the embed code? If so, here is the addition to the embed code:
portalId: 'xxxxxx',
redirectUrl: 'url goes here',
formId: 'd9005302-a859-4a39-9d47-74d8a1d25fb0'
I actually figured out a proper solution without having to do any redirects or hairy coding.
First I setup a local host, which was my biggest issue, this helps with getting the actual hubspot form to show within my page (using a local show the embedd code does not appear, although obvious to others, it took me a sec). Oh, I should mention that the code is not necessary.
Once you have it showing you basically inspect the element and then add to the classes that hubspot spits out get it to look that way you want too.

clicking on a div is not submitting form in Chrome on localhost

I think I have found an interesting problem (at least to me). I have a form that uses a click on a div inside the form to submit. I have used "document.forms.form.submit()" to make the div clickable to submit as suggested here this.form.submit() not working after clicking div element in form (thanks David Hedlund!)
However the form was working fine in chrome, ff. But for some unknown reason, running the form in localhost on chrome is not working now. ff is working fine. What makes the problem interesting is when I uploaded the form to a web-server it works in chrome! Any Idea why this is happening in local machine? I am using Xampp.
Here is the form-
<form name="form" action="login_process.php" method="POST">
<div>
Username: <input style="width:100px;" name="login_client[]" type="text" />
Password: <input style="width:100px;" name="login_client[]" type="password" />
</div>
<div align="right" class="whitearial12" style="position:absolute; font-size:10px; width:360px; height:17px; right:110px; top:35px;">
Forgotten your password, or need to register?
</div>
<!-- this is the div !-->
<div onClick="document.forms.form.submit()" align="center" class="whitearial12" style="cursor: pointer; position:absolute; padding-top:3px; padding-bottom:-3px; width:80px; height:17px; right:20px; top:10px; background-image: url(Images/button_blank.png); background-repeat:no-repeat">
Log In
</div>
</form>
Update: Let me add what I noticed further. This form is included in index.php file from another php file named header.php. I have tried running only the header.php. The form works alright in that case in chrome. But including it in index.php does not work.
I would suggest including jQuery and reworking to resemble this
<form id="MyForm" action="login_process.php" method="post">
<span onclick="javascript:$('#MyForm').submit();">Magical ponies await</span>
</form>
Using jquery can help with cross-browser issues a lot, but if you can't do that, how about
<form id="XX" action="login_process.php" method="post">
<span onclick="javascript:document.getElementById('XX').submit();">AVAST</span>
</form>

Tumblr: Search returning no search results

I'm new to tumblr and am trying to implement Search in a custom theme. I have:
<form action="/search" method="get" id="search-form">
<input type="text" name="q" class="query" value="" />
<input type="submit" value="Search" class="submit" />
<div class="clear"></div>
</form>
I have about a dozen posts. Whenever I search for anything in any post, Tumblr always returns no search results. I feel like I'm missing something. Am I to implement or set any configuration anywhere else in the theme? What else is needed to implement search in a user's Tumblr theme?
Thanks!
Here's the solution I use. Put this into the <head> of your code:
<script type="text/javascript">
<!--
function handleThis(formElm)
{
window.location="/tagged/"+formElm.number.value+"";
return false;
}
-->
</script>
And place this where you want the search box to appear:
<form onsubmit="return handleThis(this)">
<div class="submit"><input type="submit" value="{lang:Search}" name="Submit"/></div>
<div class="input"><input onfocus="this.value=''" onblur="if(this.value=='') this.value='Search. Then hit enter.';" type="text" value="{lang:Search}. Then hit enter." name="number"/></div>
</form>
Use CSS to style as you wish. This will search your tags only, but unlike the regular Tumblr search it works.
I was getting no results when my blog was password protected. I removed the password protection from Tumblr Dashboard > settings > blog name > password and it started returning results again.