Guide 10 · Developer docs

Forms and data capture

Building forms with the Forms module: how a form is put together and placed on a page, validating and branching, presenting it, where submissions are stored, and what happens after one arrives, from jobs and records to CRMs and payments.

7
units
20
pages

A form on Core dna is a record like a page: a tree of steps, groups and elements, with its own layout and layout areas, revisions and publishing. Submissions are stored as records too, and what happens next is the job of the Orchestration module. This guide follows a form from building it to acting on what it collects.

Who this guide is for

Theme developers who render and style forms, content modellers who build them in the admin, and integrators who send submissions on to other systems. It assumes you know layouts and templates (Input types, layouts, components and images) and, for the last unit, jobs (Automation, jobs and integration). Every template example is given in both engines.

The units, in order

  1. Building a form: how a form is put together and placed on a page, its fields, groups and static elements, and multi-step forms.
  2. Validating answers: what the server checks, how a rejected submission comes back, and accessible error messages.
  3. Branching forms: showing and hiding fields, groups and steps by earlier answers.
  4. Presenting a form: the markup the platform prints, styling it, client-side helpers and the captcha.
  5. Storing submissions: reading and exporting them, file uploads, retention and privacy, and submitting through the API.
  6. Acting on a submission: jobs, notifications and confirmations, creating records, pushing to a CRM, and taking payments.
  7. Reference: every input type, and the platform's three form scripts.

Two ways to run a form

The platform supports two submission models, and the choice affects almost everything else in this guide. The form layout decides which one a form uses.

Page per stepAll steps in one page (JS)
How it submitsAn ordinary POST to the page the form is on, one step at a timeThe platform's /assets/forms/js-forms.js moves between steps in the browser, then sends every step in one JSON POST to /cdna-api/forms/submission/<form id>
Stored between stepsYes: each step is saved as it is submitted, and a token in the page ties the steps togetherNothing, until the final submit. A reload loses everything typed
Back to an earlier stepNo. The server always shows the first step that is not yet validYes: .navigate-previous and .go-to-step links
Conditions that look at an earlier stepNot on the server, which sees only the current step's answers. See Conditional logicYes: every answer arrives together
Works without JavaScriptYesNo
Validation errorsThe step is rendered again with the answers kept and an error under each failing fieldReturned as JSON. Add the handling on Validation rules and error handling so that the visitor's answers are kept

Use page per step for one-step forms and for anything that must work without JavaScript. Use the JS layout for multi-step forms whose later steps depend on earlier answers, or that need a back button, together with the error handling on the validation page. The details of each are on Multi-step forms.

Five things to know first

  1. Every form needs a layout with a template. Check the layout first when you place a form (How a form is put together).
  2. Branching on an earlier step needs the JS model. The server sees only the current step's answers, so a condition that looks further back needs the JS submission model (Conditional logic).
  3. The CSRF token is for signed-in members only. Public forms are not CSRF-checked, and _csrfToken exists only when someone is signed in, so print it guarded (How a form is put together).
  4. Uploaded files are public. A form's uploads go to the file manager, where anyone with the link can read them (File uploads).
  5. What follows a submission is a job. Notifications, records and CRM pushes are jobs on the form's submissions, and run in the background by default (Jobs, notifications and confirmations).

Contents

7 units, in reading order.

Building a form

How a form is built as a record, from the whole form down to a single element, and placed on a page; then which input suits which answer, and what changes once a form spans more than one step. 3 pages

Validating answers

What the server checks without being configured, the rules you add yourself, how a rejected submission comes back in each submission model, and the patterns that keep errors accessible and preserve what the visitor typed. 1 page

Branching forms

Showing, hiding and requiring fields, groups and steps as a visitor answers earlier ones, and the patterns that keep the browser and the server agreeing about what a form needs. 1 page

Presenting a form

The markup the platform prints for a form and how far you can style or override it, the client-side helpers production sites add, and the captcha element that keeps spam out. 3 pages

Storing submissions

Where a submission is stored and how to read, export and accept file uploads on it, how long the platform keeps one and how to delete it, and sending a submission from outside a Core dna page altogether. 4 pages

Acting on a submission

Everything that follows a submission is a job you build, under Customization › Orchestration (jobs were called hooks before the module was renamed). Starting one, creating records, pushing to a CRM and taking payments. 4 pages

Reference

Every element the form builder offers, and the three scripts the platform ships to run a form in the browser: the JS submission model, its conditional logic and its payment element. Look things up here rather than in the units that explain them. 4 pages