Cp

Type
Class
Namespace
craft\helpers
Inherits
craft\helpers\Cp
Since
3.0.0

Class Cp

View source (opens new window)

# Public Methods

Method Description
alerts()
autosuggestFieldHtml() Renders an autosuggest field’s HTML.
checkboxFieldHtml() Renders a checkbox field’s HTML.
checkboxSelectFieldHtml() Renders a checkbox select field’s HTML.
colorFieldHtml() Renders a color field’s HTML.
dateTimeFieldHtml() Renders a date + time field’s HTML.
editElementTitles() Returns the page title and document title that should be used for Edit Element pages.
editableTableFieldHtml() Renders an editable table field’s HTML.
elementHtml() Renders an element’s HTML.
elementPreviewHtml() Returns element preview HTML, for a list of elements.
elementSelectFieldHtml() Renders an element select field’s HTML.
fieldHtml() Renders a field’s HTML, for the given input HTML or a template.
lightswitchFieldHtml() Renders a lightswitch field’s HTML.
metadataHtml() Returns a metadata component’s HTML.
renderTemplate() Renders a control panel template.
selectFieldHtml() Renders a select field’s HTML.
selectHtml() Renders a select input.
textFieldHtml() Renders a text field’s HTML.
textareaFieldHtml() Renders a textarea field’s HTML.

# alerts()

View source (opens new window)

Arguments

Returns

array (opens new window)

# autosuggestFieldHtml()

Since
3.7.0

Renders an autosuggest field’s HTML.

View source (opens new window)

Arguments

Returns

string (opens new window)

Throws

# checkboxFieldHtml()

Since
3.6.0

Renders a checkbox field’s HTML.

Note that unlike the checkboxField macro in _includes/forms.html, you must set the checkbox label via $config['checkboxLabel'].

View source (opens new window)

Arguments

Returns

string (opens new window)

Throws

# checkboxSelectFieldHtml()

Since
3.6.0

Renders a checkbox select field’s HTML.

View source (opens new window)

Arguments

Returns

string (opens new window)

Throws

# colorFieldHtml()

Since
3.6.0

Renders a color field’s HTML.

View source (opens new window)

Arguments

Returns

string (opens new window)

Throws

# dateTimeFieldHtml()

Since
3.7.0

Renders a date + time field’s HTML.

View source (opens new window)

Arguments

Returns

string (opens new window)

Throws

# editElementTitles()

Since
3.7.0

Returns the page title and document title that should be used for Edit Element pages.

View source (opens new window)

Arguments

Returns

string (opens new window)[]

# editableTableFieldHtml()

Since
3.6.0

Renders an editable table field’s HTML.

View source (opens new window)

Arguments

Returns

string (opens new window)

Throws

# elementHtml()

Since
3.5.8

Renders an element’s HTML.

View source (opens new window)

Arguments

Returns

string (opens new window)

# elementPreviewHtml()

Since
3.6.3

Returns element preview HTML, for a list of elements.

View source (opens new window)

Arguments

Returns

string (opens new window)

# elementSelectFieldHtml()

Since
3.7.0

Renders an element select field’s HTML.

View source (opens new window)

Arguments

Returns

string (opens new window)

Throws

# fieldHtml()

Since
3.5.8

Renders a field’s HTML, for the given input HTML or a template.

View source (opens new window)

Arguments

Returns

string (opens new window)

Throws

# lightswitchFieldHtml()

Since
3.6.0

Renders a lightswitch field’s HTML.

View source (opens new window)

Arguments

Returns

string (opens new window)

Throws

# metadataHtml()

Returns a metadata component’s HTML.

View source (opens new window)

Arguments

  • $data (array (opens new window)) – The data, with keys representing the labels. The values can either be strings or callables. If a value is false, it will be omitted.

Returns

string (opens new window)

# renderTemplate()

Renders a control panel template.

View source (opens new window)

Arguments

Returns

string (opens new window)

Throws

# selectFieldHtml()

Since
3.6.0

Renders a select field’s HTML.

View source (opens new window)

Arguments

Returns

string (opens new window)

Throws

# selectHtml()

Since
3.6.0

Renders a select input.

View source (opens new window)

Arguments

Returns

string (opens new window)

# textFieldHtml()

Since
3.6.0

Renders a text field’s HTML.

View source (opens new window)

Arguments

Returns

string (opens new window)

Throws

# textareaFieldHtml()

Since
3.6.0

Renders a textarea field’s HTML.

View source (opens new window)

Arguments

Returns

string (opens new window)

Throws

# Constants

Constant Description
ELEMENT_SIZE_LARGE
ELEMENT_SIZE_SMALL

# Events

# EVENT_REGISTER_ALERTS

Type
craft\events\RegisterCpAlertsEvent

The event that is triggered when registering control panel alerts.