Create a Default Form in Beefree SDK
Learn how to configure a default form in Beefree SDK that users can drag and drop onto the design stage, complete with pre-defined fields and validation.
Why Use Default Forms?
When building email campaigns, forms are essential for collecting user data like newsletter signups, survey responses, or contact information. Email recipients are typically led to these forms by clicking on a CTA (call-to-action) within the email that redirects to a landing page with the form within it. In Beefree SDK, forms can be built in both the page and popup builders. Instead of making your end users build forms from scratch every time they want to embed one within their page or popup design, you can pre-configure a default form with common field types and layouts. This default form will appear each time your end users drag and drop the Form block onto the stage for their page or popup design. Having a default form saves your end users time, and ensures consistency across content assets for their email campaigns.
With Beefree SDK's defaultForm configuration, you can:
Pre-define common form structures (contact forms, surveys, registrations)
Set up field validation rules (required fields, input types, placeholders)
Enable drag-and-drop functionality so users can easily add forms to their designs
Configure form behavior with custom handlers for save, submit, and change events
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:
Single default form implementation
How to configure beeConfig.defaultForm with a complete form structure
Node.js authentication proxy
How to securely authenticate with Beefree SDK using LoginV2
Data Flow Diagram
Here's how the default form system works:
Why this flow? The defaultForm configuration provides the initial form structure, and Beefree SDK handles user interactions and form editing. The event handlers track form changes, and saves the Form as part of the design's JSON.
Step 1: Clone the Project
Clone the repository and install dependencies:
Create a .env file with your Beefree SDK credentials:
Step 2: The Proxy Server Setup
File to reference: proxy-server.js
The proxy server handles secure authentication with Beefree SDK:
Step 3: Default Form Configuration
File to reference: default-form-example.html
The heart of the default form setup is the beeConfig.defaultForm object:
Step 4: Form Structure Breakdown
The defaultForm.structure object contains three main components:
Fields Definition
Each field is defined with:
type: Input type (text, select, radio, checkbox, etc.)label: Display label for the fieldattributes: HTML attributes (required, placeholder, min, max, etc.)options: For select/radio/checkbox fieldscanBeRemovedFromLayout: Whether users can remove this fieldcanBeModified: Whether users can edit field properties
Layout Array
A 2D array that defines field arrangement:
Form Attributes
Standard HTML form attributes:
Reference the full Form Validation Schema in GitHub.
Step 5: Event Handlers
File to reference: default-form-example.html (lines 307-329)
Configure event handlers to manage form interactions:
Step 6: Field Types and Validation
The default form supports various field types with built-in validation:
Step 7: Making the Form Draggable
Once configured, the default form automatically becomes available in the Beefree SDK editor:
Form Block: Users can drag a Form block from the content panel
Pre-populated: The form appears with your default structure
Editable: Users can modify fields, layout, and styling
Validation: Built-in validation based on your field definitions
Step 8: Running the Example
Start the proxy server:
Open
default-form-example.htmlin your browser. You'll see:The Beefree SDK editor loads with authentication
A pre-configured form is available in the form block
Users can drag the form block onto the design stage
The form includes all your predefined fields and validation
Advanced Configuration: Multiple Forms
If you are interested in providing your end users with a Form library of pre-existing forms they can choose from, reference the Create a Form Library in Beefree SDK documentation.
You can also reference the GitHub sample project's code to see how it is implemented: form-library-example.html
Learn More
Full example project: beefree-sdk-form-block-demo
Form documentation: Form Block Configuration
Authentication: Authorization Guide
Implementation Checklist
Set up proxy server for secure authentication
Configure
defaultForm.structurewith fields and layoutAdd event handlers for form interactions
Define field validation with HTML5 attributes
Test drag-and-drop functionality in the editor
Handle form submissions in your application
Clone the example project, explore the default-form-example.html file, and adapt the defaultForm configuration to match your specific form requirements. The pre-configured form will then be available as a draggable block in your Beefree SDK editor.
Last updated
Was this helpful?

