form_templates
This table stores reusable form definitions created inside DirtView. Each row represents a template such as a Daily Log, PTP, Safety Inspection, or other configurable field form.
Purpose
The purpose of this table is to store the reusable schema and metadata for a form template that can be filled out many times by users in the field or office.
What this table does
- Stores the definition of a reusable form
- Captures the full form structure as JSON schema/configuration
- Provides metadata such as name, version, creator, and defaults
- Acts as the parent definition for many form submissions
Why this table is defined
DirtView’s forms system is a major product differentiator. Templates must be reusable, version-aware, and independent from the submissions users create from them.
Columns
| Column | Type | Required | Description | Example |
|---|---|---|---|---|
id | uuid | Yes | Primary key for the form template | ftpl_001 |
tenant_id | uuid | Yes | Tenant owning the template | tenant_001 |
name | text | Yes | Template display name | Daily Log |
description | text | No | Optional description | Standard daily field reporting form |
version | int | Yes | Template version number | 1 |
schema | jsonb | Yes | Full component tree / form schema | {"fields":[...]} |
created_by | uuid | No | User who created the template | user_100 |
default_distribution_group_id | uuid | No | Optional default distribution group | dgroup_015 |
is_active | boolean | Yes | Whether the template can be used | true |
metadata | jsonb | Yes | Extra template metadata | {"category":"safety"} |
created_at | timestamptz | Yes | Creation timestamp | 2026-04-11 09:00:00+00 |
updated_at | timestamptz | Yes | Last update timestamp | 2026-04-11 09:30:00+00 |
Relationships
- default_distribution_group_id → distribution_groups.id
- id is referenced by form_submissions.template_id
How it is used
- Rendered by the form builder and form-filling UI
- Selected when a user begins a form submission
- Used to generate the initial field structure for submissions
- Used for admin review, export, and reporting context
Access and security
- Template creation/editing should be restricted to authorized users
- Template schema changes should be version-aware
- Field-level RBAC may eventually apply to parts of the schema
Example scenarios
Scenario 1: Daily Log template
A tenant creates a Daily Log template with crew, hours, photos, and notes fields.
Scenario 2: Safety inspection template
A Safety Manager defines a reusable form for recurring site inspections.
Scenario 3: Distribution defaults
A template is configured to notify a specific group whenever it is submitted.
Notes and assumptions
- The submission should store a snapshot of the template version used
- Do not overwrite historical meaning of old versions
- JSON schema design quality is very important here