Forms

Forms let you build user-facing forms — such as contact forms, signup forms, and surveys — directly in OptiPub. Each form belongs to a publication and can be embedded on any page using the optipub-form element. Submissions are stored in OptiPub and can optionally trigger email notifications.

Navigate to ContentForms

Creating a Form

Click the Create button to open the form editor.

FieldRequiredDescription
PublicationYesThe publication this form belongs to. Cannot be changed after creation
NameYesA name to identify the form in the admin (e.g. "Contact Us", "Newsletter Signup")
EmailNoAn email address to receive a notification each time the form is submitted
ActiveNoWhether the form is live. Inactive forms return a 404 on the public API

Form Builder

Below the form fields is a drag-and-drop form builder for designing the form layout. Add fields by dragging them from the toolbar into the form canvas. Each field can be configured inline — click a field to set its label, placeholder, options, validation, and other properties.

Available Field Types

TypeDescription
TextSingle-line text input
TextareaMulti-line text input with configurable rows and max length
NumberNumeric input with optional min/max constraints
DateDate picker
SelectDropdown menu with configurable options
Checkbox GroupMultiple checkboxes for selecting one or more options
Radio GroupRadio buttons for selecting exactly one option
HeaderHeading text (h1–h4) for structuring the form
ParagraphStatic text block (paragraph, address, or blockquote)
ButtonA submit or generic button

Every form must have at least one element. If no submit button is included, one is automatically added when the form is rendered on your website.

Editing a Form

Click on any form in the list to view it, then click Edit to make changes. All fields except Publication can be updated. The form builder lets you add, remove, and reorder fields — you'll be prompted to confirm before deleting a field.

The form also supports auto-save, which periodically saves unsaved changes every 60 seconds.

List View

The form list displays all forms across publications in a searchable, filterable data table. The following columns are available:

ColumnFilter typeDefault
IDNumberShown
PublicationSelectShown
NameText searchShown
EmailText searchShown
ActiveBooleanShown
CreatedDateHidden
UpdatedDateHidden

Each row includes a View Responses button to jump directly to that form's submissions.

Form Responses

To view submissions for a form, click the View Responses button on the form list, or navigate to ContentForms → select a form → Responses.

Each response is displayed as a card showing the label and submitted value for every form element, along with the submission timestamp.

Displaying Forms on Your Website

Forms are embedded on pages using the optipub-form element with a form-id attribute:

<optipub-form form-id="1"></optipub-form>

The element fetches the form definition from the public API and renders all configured fields. When a user submits the form:

  1. A bot protection challenge is verified (if enabled — see below)
  2. The response is saved to OptiPub
  3. If an Email address is configured on the form, a notification email is queued with the submission details
  4. The user sees a confirmation message: "Your response has been recorded. Thank you."

Bot Protection

When bot protection is enabled in your publication settings (SettingsBot Protection), form submissions are verified using Cloudflare Turnstile or reCAPTCHA. The challenge is handled automatically by the optipub-form element — no additional configuration is needed on the form itself.

Duplicate Submissions

Each visitor is identified by a tracking identifier stored in the optipub cookie. If a visitor has already submitted a particular form, the form will display the success message instead of rendering the fields again, preventing duplicate submissions.

Email Notifications

When a form has an Email address set, each submission triggers a notification email to that address. The email contains the form name followed by each element's label and the submitted value.

Notification emails are queued and sent asynchronously to avoid slowing down the submission response.

Dynamic Form Pages

Forms can be used with dynamic pages. By setting a page path to {$sys_form.slug}, OptiPub generates an individual page for each form. Inside the page content, use system macros like {$sys_form.name} to render form data dynamically.