Skip to content

Field decorators

Decorate entry field values for display — markdown, HTML, and type decorators.

Field decorators transform raw stored values into display-ready output. Call $entry->decorate() to apply type-specific decorators registered on field types.

When to use decorators

Use decorators in views when you need formatted output (rendered markdown, humanized dates) without mutating the stored value.

Basic usage

example.php
$html = $entry->decorate('body');

Each field type may register a decorator that knows how to format its value. String fields with config.markdown set to true return parsed HTML when the decorator is cast to a string.

example.json
{ "handle": "body", "type": "string", "config": { "markdown": true } }
example.php
echo $entry->decorate('body');

Protected fields

Fields marked protected: true are omitted from toArray() and toJson() but remain accessible on the entry object and through decorate() when authorized.

example.json
{ "handle": "internal_notes", "type": "string", "protected": true }

Related