Creating squarespace hidden form

Viewed 590

On squarespace, is it possible to create a hidden form (or a form out of the view), then use javascript to populate the fields, then call the submit function in the same code?

I am looking for a solution that uses code block to generate the payload then to submit it to squarespace form storage.

Thank you.

1 Answers

Yes, it is possible. It would be done similar to what you describe:

  1. Add a form block to the page in question, setting up the form fields as desired.
  2. Set the form block to display: none;, likely by targeting it via its block-id.
  3. Create your own UI for the user (if needed) via a code block or code injection.
  4. Write JavaScript code that takes the payload, parses it if necessary, matches it with the corresponding fields in the Squarespace form, sets the values, then triggers the form's submit function.
  5. Either set the CSS for the form to show the form block if it's submitted, or write your own submission/success message handler.
Related