Form Templates
Learn how to create reusable form templates, clone forms from templates and manage a template library.
Overview
The FormTemplate model enables creating reusable form blueprints. Templates store form structure, fields, steps and settings as JSON schema, allowing you to quickly clone forms without rebuilding from scratch. This is ideal for standardized surveys, applications or recurring forms.
Core Properties
Creating Templates
Create templates from existing forms using the CreateTemplateFromForm action:
Schema Structure
Templates store form data as structured JSON:
The schema includes all configuration needed to recreate the form, including conditional logic, validation rules and field relationships.
Cloning Forms from Templates
Use the Polyform facade to clone forms from templates:
Listing Templates
Use the is_active flag to control which templates are visible in template libraries or UI pickers.
Updating Templates
Updating a template does not affect existing forms cloned from it. Templates are version snapshots.
Template Metadata
Store additional information in the metadata JSON column:
Metadata enables categorization, search filtering, usage tracking and custom UI rendering.
FormBuilder Workflow
Build forms with the fluent builder, then convert to templates:
Complete Workflow
- Design and test form structure
- Create template from validated form
- Clone template for new instances
- Customize cloned forms as needed
- Update template when improvements are made
Seeding Templates
Populate your template library via database seeders:
Seeding templates ensures consistent form structures across environments and simplifies onboarding.
Schema Validation
Common Use Cases
- Recurring Surveys - Quarterly employee feedback, annual reviews
- Application Forms - Job applications, grant requests, membership forms
- Multi-Tenant SaaS - Standardized forms deployed per customer
- Industry Templates - Healthcare intake, legal questionnaires, insurance claims
- A/B Testing - Clone template, modify fields, compare submission rates
Best Practices
- Test forms thoroughly before creating templates
- Use descriptive names and detailed descriptions
- Categorize templates with metadata tags
- Version templates by including version number in metadata
- Set
is_activeto false for deprecated templates - Track usage via metadata to identify popular templates
- Regularly audit and update templates based on feedback
Extensibility
Templates are simple JSON storage and can be extended with:
- Custom schema transformations during cloning
- Template versioning systems
- Import/export functionality for sharing across apps
- Template marketplace features