Skip to content

Custom HTML Templates and Placeholders

ProcessFactorial Forms support custom HTML authoring at two levels:

  1. Field-level templates — when Render by Template is enabled on the form, each field type uses an HTML template that can be customized per data type/format.
  2. Custom sections — sections set to Custom HTML format give you full control over the entire section layout and markup.

This article covers both approaches, the placeholders available, and the runtime requirements your HTML must satisfy.


1. Field-Level Templates (Render by Template)

When Render by Template is enabled on a form, each field renders using an HTML template configured on the Form HTML Template tab. There is a separate template property for every data type and format combination.

1.1 Available template properties

Template Property Applies To
FieldStringDefault String fields with Default/SingleLine format
FieldStringSingleLine String fields with SingleLine format
FieldStringEmail String fields with Email format
FieldStringPhone String fields with Phone format
FieldStringSingleUrl String fields with URL format
FieldStringPassword String fields with Password format
FieldStringMultiLine Multi-line text fields (textarea)
FieldBoolDefault Boolean (default widget)
FieldBoolDropdown Boolean (dropdown widget)
FieldBoolRadio Boolean (radio button widget)
FieldBoolCheckbox Boolean (checkbox widget)
FieldCurrencyDefault Currency fields
FieldDateDefault Date fields
FieldDateDateAndTime Date+Time fields
FieldDateDateOnly Date-only fields
FieldDateTimeOnly Time-only fields
FieldDateYearMonth Year/Month fields
FieldDecimalDefault Decimal number fields
FieldIntDefault Integer number fields
FieldFloatDefault Float number fields
FieldLookupDefault Lookup fields (default widget)
FieldLookupDropdown Lookup fields (dropdown)
FieldLookupTypeAhead Lookup fields (typeahead)
FieldOptionSetDefault Option Set fields (default widget)
FieldOptionSetDropDown Option Set fields (dropdown)
FieldOptionSetTypeAhead Option Set fields (typeahead)
FieldOptionSetMultiSelect Multi-select option set (native <select multiple>)
FieldOptionSetMultiSelectCheckBox Multi-select option set as checkboxes
FieldOptionSetMultiSelectCheckBoxItem Single checkbox item within a multi-select group
FieldFileDefault File upload fields
FieldImageDefault Image upload fields
SelfieCaptureDialog Camera capture dialog used by enabled file/image upload fields
ControlTemplateButton Button controls
ControlTemplateModalOkCancel Modal with OK/Cancel buttons
ControlTemplateModalCustom Custom modal layout

1.2 COREMETA field placeholders

These placeholders are replaced at render time with the field's actual values. Use them inside any field-level template.

Placeholder Replaced With
[[COREMETA_FIELDINSTANCEID]] The field's unique instance ID ({Id}_{FieldSuffix}). Use this for id attributes on <input>, <select>, and <label for="..."> elements.
[[COREMETA_FIELDIDWITHSUFFIX]] Alias of [[COREMETA_FIELDINSTANCEID]]; useful for data-npo-field values in custom-section layouts.
[[COREMETA_FIELDID]] The field's logical ID (GUID, no suffix). Use for data-id attributes.
[[COREMETA_FIELDLABEL]] The field's Label text, HTML-entity-encoded. An asterisk is appended if the field is required.
[[COREMETA_FIELDHELPER]] The field's Helper/description text (may contain simple markup).
[[COREMETA_FIELDPLACEHOLDER]] The field's Placeholder text.
[[COREMETA_FIELDDEFAULTVALUE]] The field's Default Value.
[[COREMETA_FIELDREADONLY]] The literal readonly when the field is read-only, otherwise an empty string. Use on <input>/<select>/<textarea>.
[[COREMETA_FIELDREQUIRED]] The literal required when the field is required, otherwise an empty string. Use on <input>/<select>/<textarea>.
[[COREMETA_FIELDMIN]] The field's minimum value (from Data.Min), or an empty string when not set. Use for min/minlength attributes.
[[COREMETA_FIELDMAX]] The field's maximum value (from Data.Max), or an empty string when not set. Use for max/maxlength attributes.

Lookup-specific placeholders:

Placeholder Replaced With
[[COREMETA_LOOKUP_ENTITY]] The lookup entity logical name
[[COREMETA_LOOKUP_ATTRIBUTES]] The lookup attributes (key, value, additional stored attributes)
[[COREMETA_LOOKUP_ORDERBY]] The lookup ORDER BY clause
[[COREMETA_LOOKUP_KEY]] The lookup key field name
[[COREMETA_LOOKUP_VALUE]] The lookup value field name
[[COREMETA_LOOKUP_TOPX]] The lookup top X value

Option Set-specific placeholders:

Placeholder Replaced With
[[COREMETA_OPTIONSET_OPTIONS]] The full set of <option> elements for a dropdown option set
[[COREMETA_OPTIONSET_JSON]] The option set serialized as JSON, HTML-attribute encoded. Used by typeahead controls in data-options.
[[COREMETA_OPTIONSET_NAME]] The logical name of the option set (where supplied by the configured template context)

For FieldOptionSetMultiSelectCheckBoxItem, the renderer repeats the item template once per option and supports:

Placeholder Replaced With
[[COREMETA_OPTIONID]] A unique DOM ID for the checkbox option
[[COREMETA_OPTIONKEY]] The option's stored key
[[COREMETA_OPTIONVALUE]] The option's display label
[[COREMETA_OPTIONCHECKED]] checked="checked" when the option is selected, otherwise an empty string

1.3 ITEMMETA placeholders

When a field has custom properties in its Item Property Bag, each property becomes available as:

[[ITEMMETA_{PropertyKey}]]

Replace {PropertyKey} with the exact key name from the property bag configuration.

1.4 Required attributes in field templates

Field-level templates must include these elements and attributes for the runtime to work correctly:

Attribute/Element Where Purpose
class="... npo-input ..." On <input>, <select>, <textarea> Signals to the JS engine that this is a form control. Added automatically by the renderer if missing.
id On <input>, <select>, <textarea> Must be set to [[COREMETA_FIELDINSTANCEID]] for validation rules, events, and data binding to work correctly.
data-id On <input>, <select>, <textarea> Must be set to [[COREMETA_FIELDID]]. This is the logical key used by the JS runtime to read/write form data.
label for="..." On <label> Must reference the id of the input/select to ensure accessibility and click-to-focus behavior.
{field.IdWithSuffix}_validation A validation feedback element (typically a <div> with this id) The JS engine shows validation error messages here. Added automatically by the renderer if missing.

1.5 Minimal template example

<div class="form-group mb-3 field">
  <label for="[[COREMETA_FIELDINSTANCEID]]">[[COREMETA_FIELDLABEL]]</label>
  <input type="text"
         class="form-control npo-input"
         id="[[COREMETA_FIELDINSTANCEID]]"
         data-id="[[COREMETA_FIELDID]]"
         placeholder="[[COREMETA_FIELDPLACEHOLDER]]"
         value="[[COREMETA_FIELDDEFAULTVALUE]]" />
  <small class="form-text text-muted">[[COREMETA_FIELDHELPER]]</small>
  <div id="[[COREMETA_FIELDINSTANCEID]]_validation" class="invalid-feedback"></div>
</div>

2. Custom Sections

Custom sections give you complete control over the HTML inside a section. The entire section layout, labels, controls, and styling are authored directly.

2.1 Section-level placeholders

Placeholder Replaced With
[[COREMETA_SECTIONID]] The section's unique ID
[[COREMETA_SECTIONLABEL]] The section's label text
[[ITEMMETA_SECTIONLABEL]] Same as [[COREMETA_SECTIONLABEL]]
[[COREMETA_FIELD_PLACEHOLDER]] The rendered field content (injected by the renderer)

The default section template is:

<div id="section_[[COREMETA_SECTIONID]]"
     class="section container my-3 npo-section npo-section-custom">
  <h3 class="mb-4">[[COREMETA_SECTIONLABEL]]</h3>
  [[COREMETA_FIELD_PLACEHOLDER]]
</div>

2.2 Field identity attributes

Every input-like element in a custom section must have specific identity attributes.

Input-like controls (<input>, <select>, <textarea>):

Attribute Required Value Purpose
class Yes (must include npo-input) "form-control npo-input" (plus any custom classes) Signals the JS runtime this is a field control. The renderer adds npo-input automatically if missing.
id Yes {field.IdWithSuffix} (e.g., xxxxxxxx-...-xxx_001) Must match the backend's IdWithSuffix. This is used by validation rules, events, and data binding.
data-id Yes {field.Id} (the logical GUID without suffix) The logical field key used by the JS runtime for reading/writing form data.

Button controls (<button>, <a class="btn ...">):

Attribute Required Value Purpose
class Yes (must include npo-control) "btn ... npo-control" Signals the JS runtime this is a control button. The renderer adds npo-control automatically if missing.
id Yes Any unique ID. If missing, the renderer auto-generates [[COREMETA_FIELDINSTANCEID]]_btn_{n} (resolved to the field's instance id at publish). Used to match the element to field metadata.
data-id Yes {field.Id} (the logical GUID) The logical key used by the JS runtime.

Rule of thumb: Set id to IdWithSuffix ({fieldId}_{suffix}) and data-id to just {fieldId} (the raw GUID). This matches how the backend publishes validation rules and how the JS runtime looks them up.

2.3 Field container wrappers and display rules

To support show/hide, lock/unlock, and default values on a field's container (label + control together), add data-npo-field to the wrapping element:

<div class="col-12 col-md-6" data-npo-field="xxxxxxxx-...-xxx_001">
  <label for="xxxxxxxx-...-xxx_001">Full Name</label>
  <input type="text" class="form-control npo-input"
         id="xxxxxxxx-...-xxx_001"
         data-id="xxxxxxxx-...-xxx" />
</div>

The data-npo-field value can be either IdWithSuffix (preferred) or the bare field Id.

At render time, the backend injects the following onto the wrapper element:

Injected attribute Source Purpose
data-visible-codes VisibleCodes / EditableCodes / MandatoryCodes Display rule codes that control visibility
data-editable-codes EditableCodes / MandatoryCodes Display rule codes that control editability
data-mandatory-codes MandatoryCodes Display rule codes that control mandatory state
data-defaults IsReadOnly, IsRequired, IsHidden Fallback state string (R=ReadOnly, E=Editable, M=Mandatory, O=Optional, H=Hidden, V=Visible)
data-default-value DefaultValue Pre-fill value read by JS on form initialization

If data-visible-codes, data-editable-codes, or data-mandatory-codes are already hardcoded on the wrapper element, the renderer skips injection — so you can override them if needed.

2.4 Marker classes (auto-added by renderer)

When the renderer matches a control to a field (by id or data-id), it adds:

Condition Class Added
Matched <input>/<select>/<textarea> with npo-input class npo-input-custom
Matched button with npo-control class npo-control-custom

These are purely for CSS targeting and debugging.

2.5 Validation feedback element

For input fields, the renderer looks for a validation feedback element with id="{field.IdWithSuffix}_validation". If one is not found, a hidden <div> is injected at the end of the section. For custom styling, add your own:

<div id="xxxxxxxx-...-xxx_001_validation" class="invalid-feedback"></div>

2.6 Additional attributes auto-injected on controls

Attribute When Purpose
data-affects-codes Field drives one or more display rules Comma-separated list of display rule set IDs the JS runtime re-evaluates when this field changes
data-do-not-persist DoNotPersist = true on the field Prevents the field value from being saved
data-delhide DeleteValueWhenHidden = true on the field Clears the field value when hidden
data-notify-host-of-change NotifyHostOfChange = true on the field Sends a notification to the host page when the value changes
readonly + disabled IsReadOnly = true on the field Makes the field read-only and disabled
required IsRequired = true on the field Marks the field as required for native browser validation
placeholder Field has a PlaceholderText value Sets the HTML placeholder attribute
data-l-* Lookup fields in custom sections Sets lookup metadata (data-l-name, data-l-query, data-l-attrib, etc.)

2.7 Display rule code precedence (on wrappers)

When multiple code types apply to the same field, the precedence is (highest wins):

MandatoryCodes > EditableCodes > VisibleCodes

So a field in all three lists uses MandatoryCodes for its display rule behavior.


3. Navigation Templates

The form navigation (side bar, top tabs, or accordion) can also be customized via templates.

3.1 Available navigation templates

Template Property Purpose
NavigationTopTabsHTMLTemplate Full wrapper template for top tab navigation
NavigationTopTabsItemHTMLTemplate Single page item template for top tabs
NavigationTopScrollHTMLTemplate Full wrapper for horizontal scroll navigation
NavigationTopScrollItemHTMLTemplate Single page item for scroll navigation
NavigationSideHTMLTemplate Full wrapper template for side navigation
NavigationSideItemHTMLTemplate Single page item for side navigation
PageGroupHTMLAccordianTemplate Full wrapper for page group accordion navigation
PageGroupHTMLAccordianItemTemplate Single page group item template
PageGroupHTMLAccordianSubItemTemplate Sub-item template for pages within a group

3.2 Navigation template placeholders

Placeholder Replaced With
[[COREMETA_NAVID]] Form navigation container ID
[[COREMETA_ITEM_PLACEHOLDER]] All page items rendered together
[[COREMETA_PAGEID]] Single page anchor ID (#page_{pageId})
[[COREMETA_PAGETITLE]] Page navigation label or page label
[[COREMETA_GROUPID]] Page group ID
[[COREMETA_GROUPTITLE]] Page group title
[[COREMETA_ACCORDIANID]] Accordion container ID
[[COREMETA_SUBITEM_PLACEHOLDER]] Page sub-items within a group

3.3 Navigation CSS class data attributes

These attributes on the <ul> navigation element control per-page CSS class states at runtime:

Attribute Purpose
data-active-classes Applied to the active (current) page item
data-inactive-classes Applied to items not yet visited
data-valid-classes Applied to visited + valid page items
data-invalid-classes Applied to visited + invalid page items
data-in-progress-classes Applied to a page left for a previously visited page
data-active-group-classes Applied to the active page group
data-inactive-group-classes Applied to inactive page groups
data-valid-group-classes Applied to valid page groups
data-invalid-group-classes Applied to invalid page groups
data-in-progress-group-classes Applied to page groups with an in-progress page when no page in that group is active

These are set in the Form HTML Template configuration and injected at render time.


4. Page-Level Attributes

Pages rendered by the engine automatically receive:

Attribute Source Purpose
data-visible-codes EditableCodes (if set) or VisibleCodes Controls page-level visibility via display rules
data-editable-codes EditableCodes Controls page-level editability
data-defaults IsHidden flag + always "EO" prefix Fallback state string

5. Modal Control Templates

For control-button-triggered modals, the following templates are available:

Template Property Purpose
ControlTemplateModalOkCancel Simple confirmation modal with OK/Cancel buttons
ControlTemplateModalCustom Fully customized modal content

The modal template supports [[COREMETA_SectionId]] as a placeholder for the modal element ID.

The page-saving dialog and confirmation dialog templates are:

Template Placeholder Notes
PageSavingModal Shown during save operations
SectionConfirmDeleteDialog Shown when deleting a repeatable section row. Uses [[COREMETA_SectionId]] placeholder.
DataStorePollWaitDialog Shown during data store polling after submission. Supports [[FORMMETA_PollWaitTitle]] and [[FORMMETA_PollWaitMessage]].

6. Other Metadata Placeholder Families

Metadata placeholders are context-sensitive. A placeholder is replaced only by the renderer or runtime that owns its family; it is not automatically available in every template.

6.1 FORMMETA: live form values

Use FORMMETA to insert a value from the current form data:

[[FORMMETA_{fieldIdOrDataKey}]]
[[FORMMETA_{fieldIdOrDataKey}.{propertyPath}]]

The key can be a form field ID or another key stored in formData, such as the TargetFormDataKey of a form-level reference data query. Dotted paths read a nested property from an object value. For example:

<p>Country: [[FORMMETA_10000000-9900-0000-0000-000000000001]]</p>
<p>ISO code: [[FORMMETA_saCountryInfo.npo_iso2code]]</p>

FORMMETA values are resolved in rendered form content, including custom sections, modal content, and supported element attributes. They are re-resolved when form data changes. If the key or property does not exist, the resolved value is empty. An ordinary text field's value is displayed as text, so HTML tags in that value appear literally. A static HTML field can supply HTML when its token is the complete content of a non-input element.

Displaying a field value as HTML

To display HTML tags from a configured message field in a section's SectionConfirmDeleteDialog, use FORMDATA in the dialog template. This example is based on the default delete confirmation template; replace the example field ID with the ID of your message field:

<div id="[[COREMETA_SectionId]]" class="modal fade npo-group-delete-confirm-modal" tabindex="-1" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Confirm Delete</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">[[FORMDATA_10000000-9900-0000-0000-000000000001]]</div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
                <button type="button" class="btn btn-danger" data-delete-confirm-ok="true">OK</button>
            </div>
        </div>
    </div>
</div>

For example, if the message field contains Deleting this item will <strong>remove it permanently</strong>, the words inside <strong> appear in bold. An event can set the text field's value before opening the dialog. With [[FORMMETA_{fieldId}]], the same value displays as text, including the literal tags. The placeholder can be indented on a separate line between the modal body's tags as well.

Static HTML can include placeholders that refer to other static HTML fields. For example, field A can display field B, which can display field C. Keep each chain to five static fields or fewer. Do not make a field refer to itself, or create a chain that eventually returns to an earlier field (such as A → B → A).

[[FORMDATA_{fieldId}]] can also insert a static field's HTML. Apply the same chain rules to FORMDATA and FORMMETA references, including chains that use both.

If a chain contains a cycle or exceeds five fields, the form displays a short Placeholder cycle or Placeholder depth limit (5) message where the offending content would appear. The message shows the field IDs in the chain. Open the static text field named in the message, find its [[FORMMETA_...]] or [[FORMDATA_...]] reference, and remove the loop or shorten the chain. A reference to the same field in two separate places is allowed when neither path loops back.

Two reserved FORMMETA values are available specifically in the DataStorePollWaitDialog template:

Placeholder Replaced With
[[FORMMETA_PollWaitTitle]] The configured polling wait title
[[FORMMETA_PollWaitMessage]] The configured polling wait message

6.2 MESSAGEMETA: runtime error details

MESSAGEMETA placeholders are supported in configurable form messages. The runtime HTML-encodes inserted values; an unknown message placeholder is left unchanged.

Placeholder Replaced With
[[MESSAGEMETA_REASON]] The reason returned by the platform or runtime
[[MESSAGEMETA_FIELDLABEL]] The related upload field's label
[[MESSAGEMETA_MAXFILESIZE]] The upload field's maximum file size, such as 5 MB
[[MESSAGEMETA_ALLOWEDFILETYPES]] The upload field's allowed file extensions

MESSAGEMETA_REASON is supported by messages that have a runtime reason, including save, submit, authentication upgrade, integration, reference data, form load, file upload, and polling errors. The other three placeholders are specific to file upload errors. See Manage Form Messages for the message-by-message matrix.

6.3 PLACEHOLDERMETA: environment placeholder values

Use the ID of a configured NPO Placeholder to have its environment-specific value resolved server-side at render time:

[[PLACEHOLDERMETA_{placeholder-guid}]]

The braces around the GUID are optional. This family is used where configuration supports NPO Placeholder substitution, including asset values and navigation URLs. For navigation, a direct URL can contain one or more tokens, or the configured click path can consist of a single token whose value is the complete URL.

6.4 SEARCHMETA: existing-record search dialogs

These placeholders are available in the existing-record result dialog template and are resolved for each matching record:

Placeholder Replaced With
[[SEARCHMETA_ReferenceNumber]] The matching record's reference number
[[SEARCHMETA_LastModified]] The matching record's last-modified value

6.5 INTEGRATIONMETA: collection integration results

When an integration returns a collection and renders its dynamic item/tile template, every property on the current result object is available as:

[[INTEGRATIONMETA_{propertyName}]]

For example, [[INTEGRATIONMETA_label]] inserts the current item's label property. Property names are matched to the keys returned by the integration.

6.6 TILEMETA: tile content

In a tile item template, use [[TILEMETA_{PropertyKey}]] to show a property configured for an Option Set tile. Replace {PropertyKey} with the property's exact key. For example, the standard tile template uses [[TILEMETA_DefaultImageUrl]], [[TILEMETA_DefaultImageAlt]], [[TILEMETA_Name]], and [[TILEMETA_Description]]. Tile item templates also support [[TILEMETA_Key]] and [[TILEMETA_Value]] for the option key and display value.

For Lookup tiles, use TILEMETA placeholders for properties supplied with each lookup choice. A placeholder with no matching property displays as empty. ITEMMETA placeholders serve other template contexts; use TILEMETA for tile items.

6.7 Additional COREMETA template contexts

The following COREMETA placeholders belong to specialized templates and are therefore separate from the field and navigation tables above.

Control-button and tile templates:

Placeholder Replaced With
[[COREMETA_ITEM_PLACEHOLDER]] All rendered tile items in TilesHTMLTemplate
[[COREMETA_ClickAction]] The control or tile item's configured click action
[[COREMETA_ClickPath]] The control or tile item's configured click path

Summary templates:

Summary controls support two render modes. One card per page (Pages) uses SummaryHTMLPageLayer. One card per Page Group (PageGroups) wraps the pages in SummaryHTMLPageGroupLayer and renders each page with SummaryHTMLPageGroupPageLayer. The Form, Section, Field, and Section Group Divider layers are shared by both modes.

The render mode is configured on the Summary control and is independent of the form's Render Page Groups navigation setting. Existing Summary controls with no configured render mode use Pages.

A Page Group is included only when at least one of its pages produces summary content under the existing page, section, and field summary-visibility rules. Navigation-only settings such as Hide navigation and Hide from navigation do not introduce separate Summary filtering. Each included page retains its own heading and Edit target, including single-page groups.

Placeholder Template context Replaced With
[[COREMETA_SummaryPage]] SummaryHTMLFormLayer All rendered pages in Pages mode, or all rendered Page Groups in PageGroups mode
[[COREMETA_SummaryPage]] SummaryHTMLPageGroupLayer All rendered pages belonging to the current Page Group
[[COREMETA_PageGroupId]] SummaryHTMLPageGroupLayer The Page Group ID
[[COREMETA_PageGroupTitle]] SummaryHTMLPageGroupLayer The Page Group title
[[COREMETA_PageGroupCollapseId]] SummaryHTMLPageGroupLayer A unique collapse element ID for the Page Group
[[COREMETA_PageTitle]] SummaryHTMLPageLayer or SummaryHTMLPageGroupPageLayer The page title
[[COREMETA_PageCollapseId]] SummaryHTMLPageLayer or SummaryHTMLPageGroupPageLayer The unique collapse element ID for the page
[[COREMETA_GoToPage]] SummaryHTMLPageLayer or SummaryHTMLPageGroupPageLayer The link used to return to and edit the page
[[COREMETA_SummarySection]] SummaryHTMLPageLayer or SummaryHTMLPageGroupPageLayer All rendered summary sections on the page
[[COREMETA_SectionTitle]] SummaryHTMLSectionLayer The section title
[[COREMETA_SummaryField]] SummaryHTMLSectionLayer All rendered summary fields in the section
[[COREMETA_FieldAttributes]] SummaryHTMLFieldLayer Additional attributes required by the summary row, such as a repeatable-group ID
[[COREMETA_FieldLabel]] SummaryHTMLFieldLayer The field label
[[COREMETA_FieldValue]] SummaryHTMLFieldLayer The formatted field value

Keep page Edit links in the relevant page template by using href="[[COREMETA_GoToPage]]". In PageGroups mode, the Page Group template normally owns the card wrapper while the Page Group Page template owns each page heading and Edit link. [[COREMETA_SummaryPage]] is intentionally contextual: at Form level it inserts the top-level rendered units, while at Page Group level it inserts only that group's pages.

Runtime-wide values:

Placeholder Replaced With
[[COREMETA_ReferenceData]] The current data record's reference number
[[COREMETA_RedirectToForm]] The current form URL, URL-encoded; used in authentication logout/redirect endpoints

6.7 File and image upload camera action

File Upload and Image Upload fields can optionally expose a camera action. Set the UploadsAllowCameraCapture additional property to true. The setting defaults to false, and it never overrides UploadsAllowUpload or the configured allowed file types. For a File Upload field, the configured allowed types must include a camera-compatible image output such as jpg, jpeg, png, or webp.

The built-in upload templates support this placeholder inside the field's upload action container:

[[COREMETA_FIELDTAKESELFIEBUTTONLABEL]]

The placeholder is replaced with the default button label, Take selfie. The button HTML belongs in FieldFileDefault or FieldImageDefault, not in the placeholder expansion. The built-in templates use a button with the custom class npo-selfie-button, alongside the existing Bootstrap button classes. A custom template can use the placeholder for the default label or replace it with its own text; it owns the button markup, label, icon, and styling. Keep data-selfie-trigger="true" on the button so the runtime can bind the camera action.

The renderer adds data-allow-camera-capture="true" and mobile capture="user" to the file input only when the setting is effective. Desktop and supported mobile browsers use the browser camera permission flow. The Choose image fallback opens the browser or operating-system image picker. Supported mobile browsers may offer a camera option; Windows and many desktop browsers normally open a file chooser. Camera access requires HTTPS and may also require an appropriate iframe permissions policy when the form is embedded.

The popup markup is configurable through the SelfieCaptureDialog HTML template. Set it on the DEMTheme for a shared default; a non-empty DEMForm.HTMLTemplate.SelfieCaptureDialog overrides that theme value for one form. The built-in template is used when neither level provides a value. The renderer places this dialog template with each eligible upload field, so repeating/cloning upload sections retains the correct configured dialog.

The custom dialog must have a <dialog> root, a <video>, a <canvas>, an element with role="status", and buttons with the following data-camera values so the upload runtime can attach the capture behavior:

<button data-camera="capture">Capture</button>
<button data-camera="retake">Retake</button>
<button data-camera="use" hidden>Use photo</button>
<button data-camera="fallback">Choose image</button>
<button data-camera="cancel">Cancel</button>

The markup, button labels, classes, layout, and styling can be changed in the template; retain those runtime hooks. SelfieCaptureDialog is included in the DEMTheme template editor and can also be overridden on an individual DEMForm through its HTML template. The use action is hidden until a photo has been captured successfully. The fallback is an image-picker request with a camera hint, not guaranteed direct camera access: behavior depends on the browser and operating system.

The configured allowed data types remain authoritative. Camera normalization supports configured jpg, jpeg, png, and webp output types; other image types remain available through ordinary browsing/native capture but do not enable normalized live camera capture. This is intentional: the browser canvas is required to support PNG, while JPEG and WebP support is common but not universal, so the runtime verifies the returned blob type before accepting it.


7. Common Pitfalls and Best Practices

7.1 Pitfalls

Issue Symptom Cause
Wrong id on input Validation rules not applied, events don't fire, TrimOrRemoveInvalidCharacters doesn't work id doesn't match IdWithSuffix. JS looks up validation rules using input.id.
Missing data-id Field value not saved/submitted JS runtime binds to data-id for form data operations.
Multiple inputs with same id Only the first element is found by document.getElementById All field instances must have unique IDs. Use IdWithSuffix.
Missing npo-input class Input not recognized as a form control The JS runtime's inputHandler checks for classList.contains("npo-input").
Wrong validation element id Validation error messages don't appear Must exactly match {field.IdWithSuffix}_validation.
Hardcoding data-visible-codes instead of using data-npo-field wrapper Display rules don't apply to the container The renderer only injects visibility/editable/mandatory codes onto data-npo-field wrappers.
Using \d shorthand in regex with TrimOrRemoveInvalidCharacters Characters not removed correctly The sanitization logic extracts character classes from [...] syntax; \d is not recognized. Use [0-9] instead.

7.2 Best Practices

  1. Always use [[COREMETA_FIELDINSTANCEID]] for id and [[COREMETA_FIELDID]] for data-id in field templates.
  2. In custom sections, manually set id="{fieldId}_{suffix}" and data-id="{fieldId}" on every input/select/textarea.
  3. Add data-npo-field="{IdWithSuffix}" on a wrapping <div> around each field's label and control for proper display rule support.
  4. Include a validation feedback element with id="{field.IdWithSuffix}_validation" for every input.
  5. Prefer [0-9] over \d in regex validation patterns when using TrimOrRemoveInvalidCharacters.
  6. Avoid hardcoding field-specific logic in templates — use placeholders so the template works for any field.
  7. Test with the form tester after any template change to verify validation, events, and data persistence still work.

8. Runtime Data Attributes Reference

The following data attributes are read or written by the PF Forms JS runtime:

Attribute Set By Read By Purpose
data-id Template/custom section author JS runtime Logical field key for form data operations
data-npo-field Custom section author Backend renderer Identifies the field container for display rule attributes
data-affects-codes Backend renderer JS runtime Re-evaluates display rules when this field changes
data-visible-codes Backend renderer JS runtime Display rule codes controlling visibility
data-editable-codes Backend renderer JS runtime Display rule codes controlling editability
data-mandatory-codes Backend renderer JS runtime Display rule codes controlling mandatory state
data-defaults Backend renderer JS runtime Fallback state string
data-default-value Backend renderer JS runtime Initial value to populate
data-do-not-persist Backend renderer JS runtime Skips persistence for this field
data-delhide Backend renderer / author JS runtime Clears value when field is hidden
data-notify-host-of-change Backend renderer / author JS runtime Notifies host app on value change
data-l-name Template/custom section author JS runtime Lookup entity name
data-l-query Template/custom section author JS runtime Lookup filter query
data-l-attrib Template/custom section author JS runtime Lookup additional attributes
data-l-key Template/custom section author JS runtime Lookup key field
data-l-value Template/custom section author JS runtime Lookup value field
data-l-orders Template/custom section author JS runtime Lookup ORDER BY
data-l-topx Template/custom section author JS runtime Lookup max results
data-active-classes Form HTML Template config JS runtime CSS class for active navigation item
data-inactive-classes Form HTML Template config JS runtime CSS class for inactive navigation item
data-valid-classes Form HTML Template config JS runtime CSS class for valid navigation item
data-invalid-classes Form HTML Template config JS runtime CSS class for invalid navigation item
data-hide-navigation Custom section author JS runtime Hides a page from navigation when set to "true"
data-selfie-trigger DEM Theme author / renderer JS runtime Marks the theme-controlled button that opens camera capture
data-allow-camera-capture Backend renderer JS runtime Enables the camera action for an upload input when set to "true"
data-token Backend renderer JS runtime Form encryption token
data-auth-use-pkce Template author JS runtime Enables PKCE auth flow
data-multiselect Template author JS runtime Enables multi-select behavior on checkbox groups or <select multiple>