Embedding forms

Last updated:

This article describes how Formcentric forms are embedded into a website.

General embedding

Formcentric forms must be correctly embedded in a web page before they can be displayed and used.

Embedding is completed in just a few steps. First, you will need to make the necessary domain settings in the Organisation section of the My domains area. Here, you need to add the domains and/or subdomains for the websites on which you intend to embed your forms. Read for more information Managing domains.

You can then copy the embedding code and include it in the HTML markup of the web page on which the form will be displayed.

Basic procedure

Add script tag

Add the script tag to the <head> or at the end of the <body> of your web page:


Add form container

Add the form container at the point where you want to display your form:


After adding the embedding code, the form is loaded and displayed automatically.


Example


Including a local theme

If theme resources should not be supplied by Formcentric but provided locally from your website, then their paths can be configured directly on the form container.


Two separate approaches are possible here.

Variant 1: Theme via theme directory and theme name


Variant 2: Configure theme files explicitly


Dynamic initialisation and re-initialisation

In Static mode, all existing form containers are initialised after loading the script. If containers are only added to the DOM later, three mechanisms are available for this.

  1. Manual re-initialisation via window.formcentric.initFormcentric()

This re-initialises all currently available <div data-fc-id> containers.

  1. Automatic initialisation of new containers via data-fc-dynamic-init="true" on script tag

With this approach, the client monitors the DOM and initialises newly added form containers automatically.

  1. Re-initialisation after attribute changes via data-fc-watch="true" on form container

With this approach, the client monitors attribute changes on the form container. If an attribute change should change, the running instance is stopped and re-initialised with the new attributes.

Error handling during development

In Static mode, there are no component-based error callbacks available. For development work, debugging therefore makes use of data-fc-debug on the container, data-fc-debug on the script tag or window.formcentric.debug.

Example using the form container:


Feedback