Skip to content

Print templates ​

Print templates define custom display layouts for individual records. They are useful for generating printable views or structured summaries of complex records.

Open Templates from the sidebar (super-admin required).

TemplatesView showing a table selector, a template list, and the JSON editor panel

Structure ​

A template is a JSON object with a sections array. Each section contains a content list of fields with their display width:

json
{
  "sections": [
    {
      "label": "Basic information",
      "collapsible": false,
      "content": [
        { "field": "sigla",       "width": "1/4" },
        { "field": "periodo",     "width": "3/4" },
        { "field": "descrizione", "width": "1/1" }
      ]
    }
  ]
}

Section properties ​

PropertyTypeDescription
labelstringSection heading
typestring"accordion" to render sub-panels instead of fields (see below)
pluginstringSet to a plugin table name to show rows from that sub-table
collapsiblebooleantrue to allow the section to be collapsed (not used with accordion)
collapsedbooleantrue to render the section collapsed by default
contentarrayFor core/plugin sections: array of { field, width } objects. For accordion: array of panel objects

Field options: label, read-only, hidden ​

Each field item of a core section (and of an accordion panel) can carry three optional settings, all interface only:

json
{ "field": "stato", "width": "1/2", "label": "State of the record", "readonly": true },
{ "field": "note_revisore", "hidden": true }
OptionTypeEffect in this template
labelstring (max 200 characters)Shown instead of the field's own label. Empty = keep the field's label
readonlybooleanIn edit and create mode the value is shown but has no editor. A field that is already read-only in the table configuration stays read-only; this option can only add
hiddenbooleanThe field is left out of the form. Leaving it out of the template has the same effect; hidden keeps it listed, so it is easy to show again

Not available on plugin items ({ "plugin": …, "field": … }) nor on the content of a plugin section: saving such a template is refused (option_not_supported_on_plugin_item). A wrong type ("readonly": "yes") is refused too (invalid_readonly, invalid_hidden, invalid_label). In the template editor each field row has a Label box and Read-only and Hidden checkboxes.

Interface only, not security

These options change what the form shows. They are not permissions: a readonly field can still be written through the API, a hidden one is still readable through the API, search, filters and export, as long as the user's group rules allow it. To pin the values a group may write use an enforce rule; to keep columns out of reach use an SQL view.

Conditional visibility: visible_if ​

A field item, a section and an accordion panel can carry visible_if: the element (and everything inside it) is shown only while the condition holds.

json
{ "field": "decoration", "width": "1/2",
  "visible_if": "material = 'ceramic' and period regex '^Roman'" }
  • Fields are named by their database name; values are compared as text.
  • Operators: =, !=, >, >=, <, <= , regex (the pattern may match anywhere; use ^ and $ to anchor), in ('a', 'b'), empty, not empty. Quote values that contain spaces or symbols.
  • >, >=, <, <= compare as numbers when both sides are numbers (year > 1200, year >= -50 and year <= 100), otherwise as text, which is right for ISO dates (date >= '2020-01-01'). An empty field never satisfies them.
  • and / or combine conditions (and binds tighter); use parentheses to group.
  • Evaluated when the record opens, in read and edit mode, and again whenever a referenced field changes while editing (it follows unsaved changes).
  • A field hidden by its condition keeps its value and is still saved; the value is not cleared.
  • An invalid expression or an unknown field name keeps the element visible and writes a warning to the browser console. The server refuses a visible_if that is not a short single-line text (invalid_visible_if); not available on plugin items.

Like hidden and readonly this is interface only, not a permission.

Field width ​

Width is a fraction string. Valid values: "1/1", "1/2", "1/3", "2/3", "1/4", "3/4". Fields in a section should ideally sum to one full row.

Accordion sections ​

A section with "type": "accordion" renders its content as a series of collapsible sub-panels. Each panel has its own label and field list:

json
{
  "label": "Scheda tecnica",
  "type": "accordion",
  "content": [
    {
      "label": "Localizzazione",
      "open": true,
      "fields": [
        { "field": "sito",     "width": "1/2" },
        { "field": "ambiente", "width": "1/2" }
      ]
    },
    {
      "label": "Definizione",
      "open": false,
      "fields": [
        { "field": "categoria", "width": "1/3" },
        { "field": "tipo",      "width": "2/3" }
      ]
    }
  ]
}
Panel propertyTypeDescription
labelstringPanel heading
openbooleantrue (default) to render the panel open; false to render it collapsed
fieldsarrayArray of { field, width } objects, same format as section content

Accordion sections are ideal for tables with many fields: group logically related fields into panels so the form stays manageable without hiding data.

Plugin fields in core sections ​

A core section can also include plugin tables, in the position where you want them among the core fields. A plugin item carries the plugin table name in plugin:

json
{
  "label": "Quires",
  "content": [
    { "field": "quirenotes", "width": "1/1" },
    { "plugin": "m_quires", "field": "*", "width": "1/1" }
  ]
}
PropertyDescription
pluginPlugin table name (must be a plugin of the template's table)
fieldA plugin field name, or "*" for all plugin fields
widthWidth of the field inside the plugin table row (ignored for "*")

Plugin fields are multiple-entry: consecutive items of the same plugin are rendered together as one multi-row table, full width, at that position. With "*" all columns are shown; otherwise only the listed fields, in the listed order and widths. Two groups of the same plugin separated by core fields show the same data twice.

In the template editor the field picker groups core fields and plugin fields (Plugin › field, and Plugin › * (all fields)); plugin sections and items are marked with an orange badge and border to tell them apart from core fields. Plugin items are not available inside accordion panels.

Plugin sections ​

With "plugin": "table_name" the section shows the rows of that sub-table. content is required but may be an empty array: in that case all plugin fields are shown. List fields in content to choose their order and width.

JSON editor ​

The template editor has a Visual / JSON code switch. In JSON mode you can paste or edit the whole template (sections, accordions and plugin sections). Switching back to Visual requires valid JSON; field names and widths are validated by the server on save; if validation fails, the errors are listed above the editor and nothing is saved.

Creating a template ​

  1. Select the target table from the Table dropdown.
  2. Click New template and give it a name.
  3. Edit the JSON in the editor panel.
  4. Click Save.

Applying a template to a record ​

In RecordView, the Templates dropdown in the toolbar lets the user switch between available templates and the default view.

A group can assign templates to its members, per table (Record layouts per group): a user in such a group no longer sees the dropdown (one template) or sees only the assigned templates (several). Templates are shown in view, edit and create mode alike. Renaming or deleting a template here updates the groups that use it.

Not security

A template decides what is comfortable to see; it does not hide data. A field left out of a template can still be read through the API, search, filters and export.

Renaming and deleting templates ​

Use the Rename and Delete buttons in the template list.