Form
Form is a built-in tool for our page builder. It lets users create and add forms to their landing pages. These could be used to capture leads, sign up, contact, and a variety of other use cases.
Enable / Disable
Form tool is enabled by default but you can choose to disable it.
unlayer.init({
tools: {
form: {
enabled: false,
},
},
});
Usage Limit
You can put a limit to how many times Form tool can be used in a single design.
unlayer.init({
tools: {
form: {
usageLimit: 1,
},
},
});
Default Values
Form tool comes with the following default values. You can choose to change any of these.
| Property | Default Value |
|---|---|
| fields | [ { "name": "email", "type": "email", "label": "Email", "placeholder_text": "Enter email here", "show_label": true, "required": true } ] |
| formWidth | 100% |
| fieldBorder | { borderTopWidth: '1px', borderTopStyle: 'solid', borderTopColor: '#CCC', borderLeftWidth: '1px', borderLeftStyle: 'solid', borderLeftColor: '#CCC', borderRightWidth: '1px', borderRightStyle: 'solid', borderRightColor: '#CCC', borderBottomWidth: '1px', borderBottomStyle: 'solid', borderBottomColor: '#CCC', } |
| fieldBorderRadius | 0px |
| fieldPadding | 10px |
| fieldBackgroundColor | #FFFFFF |
| fieldColor | #000000 |
| fieldFontSize | 12px |
| formAlign | center |
| fieldDistance | 10px |
| labelFontSize | 14px |
| labelColor | #444 |
| labelAlign | left |
| labelPadding | 0px 0px 3px |
| buttonText | Submit |
| buttonColors | { color: '#FFF', backgroundColor: '#3AAEE0', hoverColor: '#FFF', hoverBackgroundColor: '#3AAEE0' } |
| buttonAlign | center |
| buttonWidth | 50% |
| buttonFontSize | 14px |
| buttonBorder | {} |
| buttonPadding | 10px |
| buttonMargin | 5px 0px 0px |
Here are a few examples on how to change these default values.
Fields
When someone adds a form to their design, it only has the Email field added by default. You can change that and add more fields.
unlayer.init({
tools: {
form: {
properties: {
fields: {
value: [
{
name: 'first_name',
type: 'text',
label: 'First Name',
placeholder_text: 'Enter first name here',
show_label: true,
required: true,
},
{
name: 'last_name',
type: 'text',
label: 'Last Name',
placeholder_text: 'Enter last name here',
show_label: true,
required: false,
},
{
name: 'email',
type: 'email',
label: 'Email',
placeholder_text: 'Enter email here',
show_label: true,
required: true,
},
],
},
},
},
},
});