Create a Custom Form Builder in Beefree SDK
Learn how to build a custom form builder interface that integrates with Beefree SDK, allowing end users to create forms dynamically and add them to their email designs.
Why Build a Custom Form Builder?
While pre-defined default forms are great for common use cases, sometimes your end users need complete flexibility to create custom forms from scratch. A form builder interface lets users:
Dynamically add form fields of different types (text, email, select, etc.)
Preview forms as they build them
Customize field properties like labels and options
Save and integrate forms directly into their page and popup designs
Reuse form structures across multiple campaigns
With Beefree SDK's contentDialog.manageForm handler, you can create a modal-based form builder that seamlessly integrates with the editor workflow.
Project Map: Where to Look in the Sample Project
This recipe is based on the beefree-sdk-form-block-demo GitHub project. Clone it, then explore these key files:
Complete form builder implementation
How to create a modal-based form builder with live preview
Data Flow Diagram
Here's how the custom form builder integrates with Beefree SDK:
Why this flow? The SDK triggers the form builder via contentDialog, users build forms with live preview, the structure is saved as JSON, and then integrated back into the email design.
Step 1: Clone and Setup
Clone the repository and install dependencies:
Create your .env file with Beefree SDK credentials:
Step 2: The Form Builder Modal Structure
File to reference: form-builder-example.html (lines 146-169)
The form builder uses a modal interface with two main sections:
Step 3: Form Structure Management
File to reference: form-builder-example.html (lines 213-229)
The form structure is managed as a JavaScript object that gets populated as users add fields:
Step 4: Content Dialog Integration
File to reference: form-builder-example.html (lines 271-282)
The key integration point is the contentDialog.manageForm handler:
Step 5: Dynamic Field Addition
File to reference: form-builder-example.html (lines 383-417)
The addField() function handles dynamic field creation with live preview:
Step 6: Field Type Configuration
The form builder supports multiple field types with automatic configuration:
Step 7: Live Preview System
The form builder includes a real-time preview system that shows users exactly how their form will look:
Step 8: Modal Management
File to reference: form-builder-example.html (lines 374-381)
Simple modal controls for opening and closing the form builder:
Step 9: Form Validation and Schema
Before saving, you can add validation to ensure the form structure is valid:
Step 10: Advanced Field Configuration
For more sophisticated forms, you can enhance the field addition process:
Step 11: Running the Form Builder
Start the proxy server:
Open form-builder-example.html in your browser:
SDK loads with authentication via the proxy
Drag a form block onto the design stage
Click "Edit Form" to open the form builder modal
Add fields using the field type buttons
Preview in real-time as you build your form
Save the form to integrate it into your page or popup design
Step 12: CSS Styling
File to reference: form-builder-example.html (lines 38-132)
The form builder includes responsive CSS for a custom interface:
Advanced Features
Customize the form builder further with your additions and styling. A few customization examples include:
Form Templates: Save commonly used form structures as templates:
Field Reordering: Add drag-and-drop reordering for form fields:
Learn More
Full example project: beefree-sdk-form-block-demo
Form reference documentation: Form Block Integration
Content Dialogs: Custom Dialog Handlers
Validation: Form Schema Validation
Implementation Checklist
Set up modal interface with field buttons and preview area
Configure
contentDialog.manageFormhandler for SDK integrationImplement dynamic field addition with live preview updates
Add form validation for structure integrity
Style the interface for professional appearance
Test the complete workflow from form building to design integration
Customize the form builder by adding your own advanced features like templates and field reordering
Clone the example project, explore the form-builder-example.html file, and customize the form builder interface to match your application's needs. Your users will then have a powerful tool for creating custom forms directly within their page and popup designs.
Last updated
Was this helpful?

