{field:field_id:property:slice_id}

Description

Returns a property of a slice field - by default its admin-defined display name (caption), but also its input help, data type, aliases, or the multi-value, multilingual and formatable flags. It reads the field's configuration, not any item's stored value. Give the field id (the dotted slug), the property to read, and optionally the slice id; if the slice id is omitted the slice of the item currently being rendered is used. The property defaults to name, and any unrecognised property name also falls back to name. The common use is rendering a field's label in a template - for example a table header - so the caption stays in step with the slice configuration. Aliases come back with their leading _# prefix.

Parameters

field_id required

The field whose property you want, given by its field id (the dotted slug like headline........ or a numbered alias such as text...........3). The field must exist on the target slice.

property optional default name

Which field property to return. Defaults to name. Only the properties in Allowed values do anything special; any other property name (or an empty one) falls back to returning name.

slice_id optional default current item's slice

The slice the field belongs to, as a 32-character slice id. If omitted, the slice of the item currently being rendered is used; outside any item context an omitted slice_id yields an empty string.

Examples

virtual<th>{field:headline........:name:{_#SLICE_ID}}</th><td>{headline........}</td>
ExpectedHeadline...the item's headline... (slice-dependent)
ActualExample namefield: a field label next to its value (real-world)
The most common production use: render a field's admin-defined label in a template, paired with the field's value. Passing {_#SLICE_ID} as the slice id keeps the label correct no matter which slice the view runs over. Marked virtual because the output depends on the current item and slice.
virtual{field:integer.........:alias1:9e1d2b9f88e3d6c3bf0eb967378610d6}
Expected_#NUMBER__ (the alias, with its _# prefix)
alias1, alias2 and alias3 return the field's aliases, each WITH its leading _# prefix (for example _#NUMBER__). Marked virtual because the returned _#ALIAS is itself live template syntax: if it appears in a page that is expanded again, the engine substitutes the alias for the current item's value instead of showing it literally.
test{field:headline........:name:9e1d2b9f88e3d6c3bf0eb967378610d6}
ExpectedHeadline
ActualHeadline
The simplest use: with no property given, {field:} returns the field's admin-defined display name (its caption on the Fields admin page). Here the headline field on the test slice is named Headline.
test{field:headline........:help:9e1d2b9f88e3d6c3bf0eb967378610d6}
ExpectedHeadline of the news
ActualHeadline of the news
The help property returns the field's input-help text, as set by the slice administrator. Useful for showing the same hint on a custom form that the item editor shows.
test[{field:full_text.......:is_formatable:9e1d2b9f88e3d6c3bf0eb967378610d6}][{field:headline........:is_formatable:9e1d2b9f88e3d6c3bf0eb967378610d6}]
Expected[1][]
Actual[1][]
is_formatable returns 1 when the field accepts output formatters (the :formatter syntax), otherwise an empty string. The long-text field is formatable here; the headline field is not.
test[{field:headline........:is_multi:9e1d2b9f88e3d6c3bf0eb967378610d6}][{field:headline........:is_multilang:9e1d2b9f88e3d6c3bf0eb967378610d6}]
Expected[][]
Actual[][]
is_multi returns 1 for a multi-value field and is_multilang returns 1 for a multilingual field; both return an empty string otherwise. The headline field on this slice is single-value and not multilingual, so both are empty.
test[{field:integer.........:name:9e1d2b9f88e3d6c3bf0eb967378610d6}][{field:integer.........::9e1d2b9f88e3d6c3bf0eb967378610d6}]
Expected[Number][Number]
Actual[Number][Number]
The property argument defaults to name, so an empty property behaves the same as name. Both calls return the display name of the number field, which is Number.
virtual{field:headline........:widget_new:9e1d2b9f88e3d6c3bf0eb967378610d6}
Expected(the HTML widget for a new item)
Actual
Headline of the news
widget_new returns the full HTML input control for this field as it appears in a new item, and valuetable returns an HTML table of a select field's options (key and value rows, empty if the field has no option list). Both emit markup, so they are illustrative rather than a text test.
test{field:headline........:type:9e1d2b9f88e3d6c3bf0eb967378610d6} {field:integer.........:type:9e1d2b9f88e3d6c3bf0eb967378610d6} {field:start_date......:type:9e1d2b9f88e3d6c3bf0eb967378610d6} {field:switch..........:type:9e1d2b9f88e3d6c3bf0eb967378610d6} {field:id..............:type:9e1d2b9f88e3d6c3bf0eb967378610d6}
Expectedtext int date bool id
Actualtext int date bool id
The type property returns how the field stores its value: one of pwd, date, bool, text, int or id. Shown here for a text field, a number field, a date field, a boolean (switch) field and the item-id field.
test[{field:no_such_field:name:9e1d2b9f88e3d6c3bf0eb967378610d6}][{field:headline........:no_such_prop:9e1d2b9f88e3d6c3bf0eb967378610d6}]
Expected[][Headline]
Actual[][Headline]
A field id that does not exist on the slice returns an empty string. An unrecognised property name is NOT empty: it falls back to the name property, so the second call still returns Headline. Use only the properties listed under Allowed values to get a specific property.