Home
Support Forums

Do netlify process AJAX forms as static?

Hi
I want to make a form which can create new input fields dynamically. I found Dynamic input of fields - #2 by fool that netlify treats forms as static as well. Can’t we even use AJAX forms to work in this case.

Maybe now somebody now a solution?

Hi @inamkbmail,

Netlify forms need the fields to exist during deploy time. So if you need 10 fields in the form in total, you need to include those 10 fields in static HTML somewhere in the deploy. Once those fields are detected, you can use JavaScript to add/remove the fields that you’ve declared in the static version.

AJAX submissions have nothing to do with this and work just fine as long as the form is setup correctly.

1 Like

Thank you for your response. Just to clarify, we knew that forms input works only if name attribute is set. Do I just have to add input fields even without any attribute or netlify needs the name attribute or any other?

What possible workaround comes to my mind is I make empty hidden fields with just name attribute (or even without name) just like placeholder fields and then replace them with dynamic created field but keep the name attribute same?

Yes, the name attribute is required for all forms. Instead of adding hidden fields in the DOM, you could do like I said, create a HTML file (say form.html) and add the static version of your form with all the inputs, their names, etc. in that version, On your actual page, you can then add the entire form dynamically and it would still work as long as it matches the static form.