Redactor field
The redactor field allows the editor to enter rich text formatted using the Redactor plugin provided by Craft CMS.
myRedactorField:
type: redactor
This field definition creates the following input in the control panel:
You must install the Craft Redactor plugin from the plugin store in order to use this field type.
Attributes
Property | Description |
---|---|
group | Starts a new field group. |
instructions | Additional instructions for this field in the control panel. Will be shown beneath the field label. |
label | The primary `label` of the input field in the control panel. When omitted, a label will be generated from the name of the field. |
purifierConfig | Allows you to configure the html purifier. |
redactorConfig | Specifies the redactor config to use. Defaults to :code:`Standard.json`. |
rules | The validation rules of the field. |
translatable | Defines whether the text field will be translated when synchronizing content fields across sites. Defaults to false. |
width | The width of the field in the control panel. |
purifierConfig
Allows you to configure the html purifier. A list of all available purifier options can be found here: http://htmlpurifier.org/live/configdoc/plain.html
purifierConfig:
Attr.EnableID: true
Attr.AllowedFrameTargets: - \_blank
HTML.AllowedComments: - pagebreak
redactorConfig
Specifies the redactor config to use. Defaults to :code:Standard.json
.
redactorConfig: Simple.json
translatable
Defines whether the text field will be translated when synchronizing content fields across sites. Defaults to false.
translatable: true
Templating
Printing the redactor field will return html contents of the field. Remember to apply the raw filter when doing this:
label: Redactor field demo
fields:
redactorField:
type: redactor
---
{{ redactorField|raw }}
html
Returns the html contents as a twig html node.
{{ redactorField.html }}