Cp ​
- Type
- Class
- Namespace
- craft\helpers
- Inherits
- craft\helpers\Cp
- Since
- 3.0.0
Class Cp
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()
​
Arguments ​
Returns ​
autosuggestFieldHtml()
​
- Since
- 3.7.0
Renders an autosuggest field’s HTML.
Arguments ​
$config
(array)
Returns ​
Throws ​
- yii\base\InvalidArgumentException
if$config['siteId']
is invalid
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']
.
Arguments ​
$config
(array)
Returns ​
Throws ​
- yii\base\InvalidArgumentException
if$config['siteId']
is invalid
checkboxSelectFieldHtml()
​
- Since
- 3.6.0
Renders a checkbox select field’s HTML.
Arguments ​
$config
(array)
Returns ​
Throws ​
- yii\base\InvalidArgumentException
if$config['siteId']
is invalid
colorFieldHtml()
​
- Since
- 3.6.0
Renders a color field’s HTML.
Arguments ​
$config
(array)
Returns ​
Throws ​
- yii\base\InvalidArgumentException
if$config['siteId']
is invalid
dateTimeFieldHtml()
​
- Since
- 3.7.0
Renders a date + time field’s HTML.
Arguments ​
$config
(array)
Returns ​
Throws ​
- yii\base\InvalidArgumentException
if$config['siteId']
is invalid
editElementTitles()
​
- Since
- 3.7.0
Returns the page title and document title that should be used for Edit Element pages.
Arguments ​
$element
(craft\base\ElementInterface)
Returns ​
string[]
editableTableFieldHtml()
​
- Since
- 3.6.0
Renders an editable table field’s HTML.
Arguments ​
$config
(array)
Returns ​
Throws ​
- yii\base\InvalidArgumentException
if$config['siteId']
is invalid
elementHtml()
​
- Since
- 3.5.8
Renders an element’s HTML.
Arguments ​
$element
(craft\base\ElementInterface) – The element to be rendered$context
(string) – The context the element is going to be shown in (index
,field
, etc.)$size
(string) – The size of the element (small
orlarge
)$inputName
(string, null) – Thename
attribute that should be set on the hidden input, if$context
is set tofield
$showStatus
(boolean) – Whether the element status should be shown (if the element type has statuses)$showThumb
(boolean) – Whether the element thumb should be shown (if the element has one)$showLabel
(boolean) – Whether the element label should be shown$showDraftName
(boolean) – Whether to show the draft name beside the label if the element is a draft of a published element$single
(boolean) – Whether the input name should omit the trailing[]
Returns ​
elementPreviewHtml()
​
- Since
- 3.6.3
Returns element preview HTML, for a list of elements.
Arguments ​
$elements
(craft\base\ElementInterface[]) – The elements$size
(string) – The size of the element (small
orlarge
)$showStatus
(boolean) – Whether the element status should be shown (if the element type has statuses)$showThumb
(boolean) – Whether the element thumb should be shown (if the element has one)$showLabel
(boolean) – Whether the element label should be shown$showDraftName
(boolean) – Whether to show the draft name beside the label if the element is a draft of a published element
Returns ​
elementSelectFieldHtml()
​
- Since
- 3.7.0
Renders an element select field’s HTML.
Arguments ​
$config
(array)
Returns ​
Throws ​
- yii\base\InvalidArgumentException
if$config['siteId']
is invalid
fieldHtml()
​
- Since
- 3.5.8
Renders a field’s HTML, for the given input HTML or a template.
Arguments ​
$input
(string) – The input HTML or template path. If passing a template path, it must begin withtemplate:
.$config
(array)
Returns ​
Throws ​
- craft\web\twig\TemplateLoaderException
if $input begins withtemplate:
and is followed by an invalid template path - yii\base\InvalidArgumentException
if$config['siteId']
is invalid
lightswitchFieldHtml()
​
- Since
- 3.6.0
Renders a lightswitch field’s HTML.
Arguments ​
$config
(array)
Returns ​
Throws ​
- yii\base\InvalidArgumentException
if$config['siteId']
is invalid
metadataHtml()
​
Returns a metadata component’s HTML.
Arguments ​
$data
(array) – The data, with keys representing the labels. The values can either be strings or callables. If a value isfalse
, it will be omitted.
Returns ​
renderTemplate()
​
Renders a control panel template.
Arguments ​
Returns ​
Throws ​
- craft\web\twig\TemplateLoaderException
if$template
is an invalid template path
selectFieldHtml()
​
- Since
- 3.6.0
Renders a select field’s HTML.
Arguments ​
$config
(array)
Returns ​
Throws ​
- yii\base\InvalidArgumentException
if$config['siteId']
is invalid
selectHtml()
​
- Since
- 3.6.0
Renders a select input.
Arguments ​
$config
(array)
Returns ​
textFieldHtml()
​
- Since
- 3.6.0
Renders a text field’s HTML.
Arguments ​
$config
(array)
Returns ​
Throws ​
- yii\base\InvalidArgumentException
if$config['siteId']
is invalid
textareaFieldHtml()
​
- Since
- 3.6.0
Renders a textarea field’s HTML.
Arguments ​
$config
(array)
Returns ​
Throws ​
- yii\base\InvalidArgumentException
if$config['siteId']
is invalid
Constants ​
Constant | Description |
---|---|
ELEMENT_SIZE_LARGE | |
ELEMENT_SIZE_SMALL |
Events ​
EVENT_REGISTER_ALERTS ​
The event that is triggered when registering control panel alerts.