Embedded Forms

You can embed a form on your own website, and users can fill out this form to generate a PDF. You can redirect users to a different page after they have filled out the form, or run some code in a JavaScript callback.

Configure Template Privacy Settings

First, you will need to go to your template's settings and make sure that "Online Form Privacy" is set to "Public". This will allow unauthenticated users to fill out your embedded form.

You may also want to set "Submission Privacy" to "Public". When this is set to "Private", the user can save the form, but they will not be able to see when the PDF has been processed. They will also not be able to download the generated PDF.

When "Submission Privacy" is set to "Public", the user can wait until the PDF has been processed, and you can show them a link to download the PDF.


Embed Code

Copy the following code into your page, replacing TEMPLATE_ID with your template id:

<link rel="stylesheet" href="https://formapi.io/assets/embed/form.v1.css" />
<script type="text/javascript" src="https://formapi.io/assets/embed/form.v1.js"></script>

<div class="fa-form"></div>
  FormAPI.createForm('.fa-form', 'TEMPLATE_ID');

Here is a more complex example that uses all of the options for FormAPI.createForm():

Redirect to a URL

After the user submits the form, you can redirect them to a different URL. The redirect URL can be configured in the template settings, or can be passed as an option to FormAPI.createForm() (The createForm option will override the template's redirect URL.)

The submission ID, template ID, and template name will be appended to this URL as query params:

When "Submission Privacy" is set to "Private", the user will be redirected as soon as the form has been saved.

When "Submission Privacy" is set to "Public", the user will be redirected after the PDF has finished processing. If you don't need to wait, you can set the waitForPDF option to false when calling FormAPI.createForm().

JavaScript API

FormAPI.createForm(css_selector: string, template_id: string, options_and_callbacks = {})


Option Description
showClearButton Set to false to remove the "Clear" button
clearButtonLabel Clear button text (Default: "Clear")
submitButtonLabel Submit button text (Default: "Submit Form")
submitButtonSavingLabel Submit button text while saving (Default: "Saving...")
submitButtonProcessingLabel Submit button text while waiting for the PDF (Default: "Generating PDF...")
redirectURL Redirect to this URL after submitting the form (Overrides the template's redirect URL)
waitForPDF Set to false to redirect immediately, instead of waiting for the PDF to finish processing. (If "Submission Privacy" is set to "Private", we will always redirect immediately and this option will have no effect.)


Callback Parameters Description
onClearForm - Called after the clear button is pressed
onSubmit formData Called when the submit button is pressed. Parameter is an object with all form data.
onSave submission Called when the form has been saved. Parameter is an object containing the submission attributes, including id.
onProcessed submission Called when the PDF has been processed. (Will only be called if "Submission Privacy" is set to "Public".) Parameter is an object containing the submission attributes, including id, download_url, and expires_at.
onError response Called if there is an error with the request. Parameter is the response from the AJAX request.

results matching ""

    No results matching ""