What You’ll Learn
- what are Form Builder theme layouts
- how to use layouts in forms
- how to create a new layout
In this section, you learn all about the Form Builder theme layouts.
Every form you create via the Form Builder app has a layout, which lets you define the design of your forms.
Because the form layout is a React component, there are virtually no restrictions when it comes to adding customizations. Feel free to organize the code to your liking, import custom CSS, fonts, or even additional custom React components if there's a need for it.
Be default, every form has a default layout, which can be changed via the form settings. In the Form Builder, click on the settings icon in the top right corner:
You should then see the following screen, and the "Layout" field at the bottom of the general settings form:
Please note that a single form layout can be used on any number of forms, but every single form can use only one layout.
Let's take a closer look at the structure of a form layout and its component.
The following snippet of code shows how to add a new form layout via a simple plugin:
The plugin is defined once but must be registered both in your admin and website apps. It enables you to do both:
- see the form preview in the Form Builder editor
- and show your form on the actual website
The following table shows a list of all keys and values that the plugin must define:
|Unique plugin name.|
|Plugin type must equal to |
|Object containing a unique |
To get a better feeling of what's expected of a single form layout component, you can check out the default layout component, located at:
If needed, feel free to edit the file to your liking, or just create a copy and, use that as a foundation for a new form layout.
|Returns a single form field by given ID.|
|Returns a list of all form fields.|
|Returns default values for all form fields.|
|A components that shows Google reCAPTCHA, a simple check that prevents you from spammers and bots (only if enabled via |
|A component that shows terms of service message (only if enabled via |
|Call this callback to submit the form.|
|Contains data about the form, for example, form name, layout, settings, and so on.|
You can add a new form layout in the Form Builder app in these two simple steps:
- create a React component that contains all the logic related to the layout
- then, register it as a
Let's start with creating a React component for our form layout.
First copy over the content of the
DefaultFormLayout component and make the following changes:
Also, make the following style changes to make our layout stand apart:
Now that you have your newly created React component in place,
let's register a new
form layout plugin:
After making these changes head over to the Form Builder app and try using your newly added form layout.