Field types

Template field

Two families of field types for displays that none of the built-in field types covers. Both store values like their base type (text, integer, decimal number) and replace only the display in the layout. What the people entering data see is described under Template field .

FamilyField typesEdited under
HTML templatecustom_text, custom_int, custom_decimalCustom code › HTML template
Componentcustom_svelte_text, custom_svelte_int, custom_svelte_decimalCustom code › Svelte component

With custom_int and custom_decimal the value has to remain a number; with custom_int without decimal places.

HTML template

The template is kept in the configuration under html and is not compiled. Placeholders consisting of the key in double curly braces are replaced before output:

PlaceholderContent
valuethe stored value; with custom_int and custom_decimal the number without trailing zeros (48000, 12.5)
formattedwith custom_int and custom_decimal the number with thousands and decimal separators (48 000, 12,5). The separators come from thousandsSeparator and radix in the configuration; if they are not given, space and comma as in the number field. For text the same value as value
labelthe field label
field_value_idnumber of the data field, usable as id in the markup
object_id, project_idobject and project
sample_datasample content of the field, otherwise the value

Further placeholders give access to the other properties of the field. Older templates with the German names inhalt, formatiert, datenfeldID, objektID, projektID and sampledata are still filled in.

Two templates from the demo collection: “Nummernschild” (number plate; custom_int, with label_visible: false) and “Schildvorschau” (label preview; custom_text).

Example Result
HTML
<!-- Number plate -->
<span style="font-size:150%;font-variant-numeric:tabular-nums">#{{value}}</span>

<!-- Label preview -->
<div style="border:1px solid #999;padding:8px;font-family:serif"><strong>{{value}}</strong></div>
Template fields in Moliri: on the left the number plate #17 in large type without a label, on the right the label preview with its label and the text Deckelgefäß mit Löwenkopfhenkeln · China, Yuan-Zeit in bold serif type inside a grey border
On the left the number plate without a label, the number 17 at one and a half times the size with a hash sign in front. On the right the label preview with label, border and serif font.

For amounts of money, formatted is the right choice. With the following template a custom_decimal field shows the stored value 48000.00000 with a thousands separator as “48 000”; the euro sign after it is part of the template:

Example Result
HTML
<span>{{formatted}} €</span>
Tile Versicherungswert (insurance value) in Moliri: the stored value 48000 appears as 48 000 with a space as thousands separator, followed by the euro sign from the template
The field Versicherungswert (insurance value) from the demo collection: the placeholder formatted inserts the stored value with a thousands separator, and the euro sign is part of the template.

If the template contains an input, select or textarea, its value is saved when it changes. Without such an element the field is display only.

Values are escaped, the template is not

Inserted values are HTML-escaped, so a value cannot smuggle in markup. The template itself is unchecked HTML. It is configuration and belongs in trustworthy hands.

Component

The source code of the component is compiled when it is saved; the result goes into the configuration under html and is not maintained by hand. A compile error appears in the editor, a runtime error in the field.

PropertyContent
fieldthe whole field entry with value and configuration
valuethe stored value
labelthe field label
object_id, project_idobject and project
statussaving state
bulkEditwhether a bulk edit is running

The component has to accept every property it uses in $props(). Otherwise the field stops with a message such as “value is not defined”. Imports follow the rules of the browser: relative paths and published packages work (packages through esm.sh), aliases such as $lib do not.

Of all the options in the data model, the custom component takes the most effort. An error in it affects every layout the field is placed on. And with every new Svelte version it has to be brought up to date.

Parameters

KeyValuesIf omittedEffect
htmlTemplate or compiled moduleemptyThe display. Without it the field stays empty
label_visibletrue, falsetruefalse leaves out the standard label when the display brings its own

Export

Exports, search and templates see the raw value, not the display. If you also need the prepared form in the export, use an output formatter or a virtual field.

When something else is the right tool

NeedBetter tool
Putting a text together from several fieldsVirtual field , without code and in the export too
A reference to an external system that sits in the fieldLink with preview
Thousands separators or a unitNumber with a suitable mask
A formatted output in the exportan output formatter
A repeated structureJSON