Property | Type | Description | |
---|---|---|---|
$attributeOrder | the preferred order of attributes in a tag. This mainly affects the order of the attributes that are rendered by BaseHtml::renderTagAttributes. | ||
$dataAttributes | list of tag attributes that should be specially handled when their values are of array type. In particular, if the value of the data attribute is ['name' => 'xyz', 'age' => 13], two attributes will be generated instead of one: data-name="xyz" data-age="13". | ||
$voidElements | list of void elements (element name => 1) |
Method | Description | |
---|---|---|
a ( string $text, array | string | null $url = null, array $options = [] ) : string | Generates a hyperlink tag. | |
activeCheckbox ( |
Generates a checkbox tag together with a label for the given model attribute. | |
activeCheckboxList ( |
Generates a list of checkboxes. | |
activeDropDownList ( |
Generates a drop-down list for the given model attribute. | |
activeFileInput ( |
Generates a file input tag for the given model attribute. | |
activeHiddenInput ( |
Generates a hidden input tag for the given model attribute. | |
activeHint ( |
Generates a hint tag for the given model attribute. | |
activeInput ( string $type, |
Generates an input tag for the given model attribute. | |
activeLabel ( |
Generates a label tag for the given model attribute. | |
activeListBox ( |
Generates a list box. | |
activePasswordInput ( |
Generates a password input tag for the given model attribute. | |
activeRadio ( |
Generates a radio button tag together with a label for the given model attribute. | |
activeRadioList ( |
Generates a list of radio buttons. | |
activeTextInput ( |
Generates a text input tag for the given model attribute. | |
activeTextarea ( |
Generates a textarea tag for the given model attribute. | |
addCssClass ( array &$options, string | array $class ) | Adds a CSS class (or several classes) to the specified options. | |
addCssStyle ( array &$options, string | array $style, boolean $overwrite = true ) | Adds the specified CSS style to the HTML options. | |
beginForm ( array | string $action = '', string $method = 'post', array $options = [] ) : string | Generates a form start tag. | |
beginTag ( string | boolean | null $name, array $options = [] ) : string | Generates a start tag. | |
button ( string $content = 'Button', array $options = [] ) : string | Generates a button tag. | |
buttonInput ( string $label = 'Button', array $options = [] ) : string | Generates an input button. | |
checkbox ( string $name, boolean $checked = false, array $options = [] ) : string | Generates a checkbox input. | |
checkboxList ( string $name, string | array | null $selection = null, array $items = [], array $options = [] ) : string | Generates a list of checkboxes. | |
csrfMetaTags ( ) : string | Generates the meta tags containing CSRF token information. | |
cssFile ( array | string $url, array $options = [] ) : string | Generates a link tag that refers to an external CSS file. | |
cssStyleFromArray ( array $style ) : string | Converts a CSS style array into a string representation. | |
cssStyleToArray ( string $style ) : array | Converts a CSS style string into an array representation. | |
decode ( string $content ) : string | Decodes special HTML entities back to the corresponding characters. | |
dropDownList ( string $name, string | array | null $selection = null, array $items = [], array $options = [] ) : string | Generates a drop-down list. | |
encode ( string $content, boolean $doubleEncode = true ) : string | Encodes special characters into HTML entities. | |
endForm ( ) : string | Generates a form end tag. | |
endTag ( string | boolean | null $name ) : string | Generates an end tag. | |
error ( |
Generates a tag that contains the first validation error of the specified model attribute. | |
errorSummary ( |
Generates a summary of the validation errors. | |
escapeJsRegularExpression ( string $regexp ) : string | Escapes regular expression to use in JavaScript | |
fileInput ( string $name, string $value = null, array $options = [] ) : string | Generates a file input field. | |
getAttributeName ( string $attribute ) : string | Returns the real attribute name from the given attribute expression. | |
getAttributeValue ( |
Returns the value of the specified attribute name or expression. | |
getInputId ( |
Generates an appropriate input ID for the specified attribute name or expression. | |
getInputName ( |
Generates an appropriate input name for the specified attribute name or expression. | |
hiddenInput ( string $name, string $value = null, array $options = [] ) : string | Generates a hidden input field. | |
img ( array | string $src, array $options = [] ) : string | Generates an image tag. | |
input ( string $type, string $name = null, string $value = null, array $options = [] ) : string | Generates an input type of the given type. | |
jsFile ( string $url, array $options = [] ) : string | Generates a script tag that refers to an external JavaScript file. | |
label ( string $content, string $for = null, array $options = [] ) : string | Generates a label tag. | |
listBox ( string $name, string | array | null $selection = null, array $items = [], array $options = [] ) : string | Generates a list box. | |
mailto ( string $text, string $email = null, array $options = [] ) : string | Generates a mailto hyperlink. | |
ol ( array | Traversable $items, array $options = [] ) : string | Generates an ordered list. | |
passwordInput ( string $name, string $value = null, array $options = [] ) : string | Generates a password input field. | |
radio ( string $name, boolean $checked = false, array $options = [] ) : string | Generates a radio button input. | |
radioList ( string $name, string | array | null $selection = null, array $items = [], array $options = [] ) : string | Generates a list of radio buttons. | |
removeCssClass ( array &$options, string | array $class ) | Removes a CSS class from the specified options. | |
removeCssStyle ( array &$options, string | array $properties ) | Removes the specified CSS style from the HTML options. | |
renderSelectOptions ( string | array | null $selection, array $items, array &$tagOptions = [] ) : string | Renders the option tags that can be used by BaseHtml::dropDownList and BaseHtml::listBox. | |
renderTagAttributes ( array $attributes ) : string | Renders the HTML tag attributes. | |
resetButton ( string $content = 'Reset', array $options = [] ) : string | Generates a reset button tag. | |
resetInput ( string $label = 'Reset', array $options = [] ) : string | Generates a reset input button. | |
script ( string $content, array $options = [] ) : string | Generates a script tag. | |
style ( string $content, array $options = [] ) : string | Generates a style tag. | |
submitButton ( string $content = 'Submit', array $options = [] ) : string | Generates a submit button tag. | |
submitInput ( string $label = 'Submit', array $options = [] ) : string | Generates a submit input button. | |
tag ( string | boolean | null $name, string $content = '', array $options = [] ) : string | Generates a complete HTML tag. | |
textInput ( string $name, string $value = null, array $options = [] ) : string | Generates a text input field. | |
textarea ( string $name, string $value = '', array $options = [] ) : string | Generates a text area input. | |
ul ( array | Traversable $items, array $options = [] ) : string | Generates an unordered list. |
Method | Description | |
---|---|---|
activeBooleanInput ( string $type, |
Generates a boolean input This method is mainly called by BaseHtml::activeCheckbox and BaseHtml::activeRadio. | |
activeListInput ( string $type, |
Generates a list of input fields. | |
booleanInput ( string $type, string $name, boolean $checked = false, array $options = [] ) : string | Generates a boolean input. |
Method | Description | |
---|---|---|
mergeCssClasses ( array $existingClasses, array $additionalClasses ) : array | Merges already existing CSS classes with new one. | |
normalizeMaxLength ( |
If maxlength option is set true and the model attribute is validated by a string validator, the maxlength option will take the value of [[\yii\validators\StringValidator::max]]. | |
wrapIntoCondition ( string $content, string $condition ) : string | Wraps given content into conditional comments for IE, e.g., lt IE 9. |
public static a ( string $text, array | string | null $url = null, array $options = [] ) : string | ||
$text | string | link body. It will NOT be HTML-encoded. Therefore you can pass in HTML code such as an image tag. If this is coming from end users, you should consider [[encode()]] it to prevent XSS attacks. |
$url | array | string | null | the URL for the hyperlink tag. This parameter will be processed by [[Url::to()]] and will be used for the "href" attribute of the tag. If this parameter is null, the "href" attribute will not be generated. If you want to use an absolute url you can call [[Url::to()]] yourself, before passing the URL to this method, like this: ```php Html::a('link text', Url::to($url, true)) ``` |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated hyperlink |
protected static activeBooleanInput ( string $type, |
||
$type | string | the input type. This can be either `radio` or `checkbox`. |
$model | the model object | |
$attribute | string | the attribute name or expression. See [[getAttributeName()]] for the format about attribute expression. |
$options | array | the tag options in terms of name-value pairs. See [[booleanInput()]] for details about accepted attributes. |
return | string | the generated input element |
public static activeCheckbox ( |
||
$model | the model object | |
$attribute | string | the attribute name or expression. See [[getAttributeName()]] for the format about attribute expression. |
$options | array | the tag options in terms of name-value pairs. See [[booleanInput()]] for details about accepted attributes. |
return | string | the generated checkbox tag |
public static activeCheckboxList ( |
||
$model | the model object | |
$attribute | string | the attribute name or expression. See [[getAttributeName()]] for the format about attribute expression. |
$items | array | the data item used to generate the checkboxes. The array keys are the checkbox values, and the array values are the corresponding labels. Note that the labels will NOT be HTML-encoded, while the values will. |
$options | array | options (name => config) for the checkbox list container tag. The following options are specially handled: - tag: string|false, the tag name of the container element. False to render checkbox without container. See also [[tag()]]. - unselect: string, the value that should be submitted when none of the checkboxes is selected. You may set this option to be null to prevent default value submission. If this option is not set, an empty string will be submitted. - encode: boolean, whether to HTML-encode the checkbox labels. Defaults to true. This option is ignored if `item` option is set. - separator: string, the HTML code that separates items. - itemOptions: array, the options for generating the checkbox tag using [[checkbox()]]. - item: callable, a callback that can be used to customize the generation of the HTML code corresponding to a single item in $items. The signature of this callback must be: ```php function ($index, $label, $name, $checked, $value) ``` where $index is the zero-based index of the checkbox in the whole list; $label is the label for the checkbox; and $name, $value and $checked represent the name, value and the checked status of the checkbox input. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated checkbox list |
public static activeDropDownList ( |
||
$model | the model object | |
$attribute | string | the attribute name or expression. See [[getAttributeName()]] for the format about attribute expression. |
$items | array | the option data items. The array keys are option values, and the array values are the corresponding option labels. The array can also be nested (i.e. some array values are arrays too). For each sub-array, an option group will be generated whose label is the key associated with the sub-array. If you have a list of data models, you may convert them into the format described above using [[\yii\helpers\ArrayHelper::map()]]. Note, the values and labels will be automatically HTML-encoded by this method, and the blank spaces in the labels will also be HTML-encoded. |
$options | array | the tag options in terms of name-value pairs. The following options are specially handled: - prompt: string, a prompt text to be displayed as the first option. Since version 2.0.11 you can use an array to override the value and to set other tag attributes: ```php ['text' => 'Please select', 'options' => ['value' => 'none', 'class' => 'prompt', 'label' => 'Select']], ``` - options: array, the attributes for the select option tags. The array keys must be valid option values, and the array values are the extra attributes for the corresponding option tags. For example, ```php [ 'value1' => ['disabled' => true], 'value2' => ['label' => 'value 2'], ]; ``` - groups: array, the attributes for the optgroup tags. The structure of this is similar to that of 'options', except that the array keys represent the optgroup labels specified in $items. - encodeSpaces: bool, whether to encode spaces in option prompt and option value with ` ` character. Defaults to false. - encode: bool, whether to encode option prompt and option value characters. Defaults to `true`. This option is available since 2.0.3. The rest of the options will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated drop-down list tag |
public static activeFileInput ( |
||
$model | the model object | |
$attribute | string | the attribute name or expression. See [[getAttributeName()]] for the format about attribute expression. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated input tag |
public static activeHiddenInput ( |
||
$model | the model object | |
$attribute | string | the attribute name or expression. See [[getAttributeName()]] for the format about attribute expression. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated input tag |
public static activeHint ( |
||
$model | the model object | |
$attribute | string | the attribute name or expression. See [[getAttributeName()]] for the format about attribute expression. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. The following options are specially handled: - hint: this specifies the hint to be displayed. Note that this will NOT be [[encode()|encoded]]. If this is not set, [[Model::getAttributeHint()]] will be called to get the hint for display (without encoding). See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated hint tag |
public static activeInput ( string $type, |
||
$type | string | the input type (e.g. 'text', 'password') |
$model | the model object | |
$attribute | string | the attribute name or expression. See [[getAttributeName()]] for the format about attribute expression. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated input tag |
public static activeLabel ( |
||
$model | the model object | |
$attribute | string | the attribute name or expression. See [[getAttributeName()]] for the format about attribute expression. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. The following options are specially handled: - label: this specifies the label to be displayed. Note that this will NOT be [[encode()|encoded]]. If this is not set, [[Model::getAttributeLabel()]] will be called to get the label for display (after encoding). See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated label tag |
public static activeListBox ( |
||
$model | the model object | |
$attribute | string | the attribute name or expression. See [[getAttributeName()]] for the format about attribute expression. |
$items | array | the option data items. The array keys are option values, and the array values are the corresponding option labels. The array can also be nested (i.e. some array values are arrays too). For each sub-array, an option group will be generated whose label is the key associated with the sub-array. If you have a list of data models, you may convert them into the format described above using [[\yii\helpers\ArrayHelper::map()]]. Note, the values and labels will be automatically HTML-encoded by this method, and the blank spaces in the labels will also be HTML-encoded. |
$options | array | the tag options in terms of name-value pairs. The following options are specially handled: - prompt: string, a prompt text to be displayed as the first option. Since version 2.0.11 you can use an array to override the value and to set other tag attributes: ```php ['text' => 'Please select', 'options' => ['value' => 'none', 'class' => 'prompt', 'label' => 'Select']], ``` - options: array, the attributes for the select option tags. The array keys must be valid option values, and the array values are the extra attributes for the corresponding option tags. For example, ```php [ 'value1' => ['disabled' => true], 'value2' => ['label' => 'value 2'], ]; ``` - groups: array, the attributes for the optgroup tags. The structure of this is similar to that of 'options', except that the array keys represent the optgroup labels specified in $items. - unselect: string, the value that will be submitted when no option is selected. When this attribute is set, a hidden field will be generated so that if no option is selected in multiple mode, we can still obtain the posted unselect value. - encodeSpaces: bool, whether to encode spaces in option prompt and option value with ` ` character. Defaults to false. - encode: bool, whether to encode option prompt and option value characters. Defaults to `true`. This option is available since 2.0.3. The rest of the options will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated list box tag |
protected static activeListInput ( string $type, |
||
$type | string | the input type. This can be 'listBox', 'radioList', or 'checkBoxList'. |
$model | the model object | |
$attribute | string | the attribute name or expression. See [[getAttributeName()]] for the format about attribute expression. |
$items | array | the data item used to generate the input fields. The array keys are the input values, and the array values are the corresponding labels. Note that the labels will NOT be HTML-encoded, while the values will. |
$options | array | options (name => config) for the input list. The supported special options depend on the input type specified by `$type`. |
return | string | the generated input list |
public static activePasswordInput ( |
||
$model | the model object | |
$attribute | string | the attribute name or expression. See [[getAttributeName()]] for the format about attribute expression. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. See [[renderTagAttributes()]] for details on how attributes are being rendered. The following special options are recognized: - maxlength: integer|boolean, when `maxlength` is set true and the model attribute is validated by a string validator, the `maxlength` option will take the value of [[\yii\validators\StringValidator::max]]. This option is available since version 2.0.6. |
return | string | the generated input tag |
public static activeRadio ( |
||
$model | the model object | |
$attribute | string | the attribute name or expression. See [[getAttributeName()]] for the format about attribute expression. |
$options | array | the tag options in terms of name-value pairs. See [[booleanInput()]] for details about accepted attributes. |
return | string | the generated radio button tag |
public static activeRadioList ( |
||
$model | the model object | |
$attribute | string | the attribute name or expression. See [[getAttributeName()]] for the format about attribute expression. |
$items | array | the data item used to generate the radio buttons. The array keys are the radio values, and the array values are the corresponding labels. Note that the labels will NOT be HTML-encoded, while the values will. |
$options | array | options (name => config) for the radio button list container tag. The following options are specially handled: - tag: string|false, the tag name of the container element. False to render radio button without container. See also [[tag()]]. - unselect: string, the value that should be submitted when none of the radio buttons is selected. You may set this option to be null to prevent default value submission. If this option is not set, an empty string will be submitted. - encode: boolean, whether to HTML-encode the checkbox labels. Defaults to true. This option is ignored if `item` option is set. - separator: string, the HTML code that separates items. - itemOptions: array, the options for generating the radio button tag using [[radio()]]. - item: callable, a callback that can be used to customize the generation of the HTML code corresponding to a single item in $items. The signature of this callback must be: ```php function ($index, $label, $name, $checked, $value) ``` where $index is the zero-based index of the radio button in the whole list; $label is the label for the radio button; and $name, $value and $checked represent the name, value and the checked status of the radio button input. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated radio button list |
public static activeTextInput ( |
||
$model | the model object | |
$attribute | string | the attribute name or expression. See [[getAttributeName()]] for the format about attribute expression. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. See [[renderTagAttributes()]] for details on how attributes are being rendered. The following special options are recognized: - maxlength: integer|boolean, when `maxlength` is set true and the model attribute is validated by a string validator, the `maxlength` option will take the value of [[\yii\validators\StringValidator::max]]. This is available since version 2.0.3. |
return | string | the generated input tag |
public static activeTextarea ( |
||
$model | the model object | |
$attribute | string | the attribute name or expression. See [[getAttributeName()]] for the format about attribute expression. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. See [[renderTagAttributes()]] for details on how attributes are being rendered. The following special options are recognized: - maxlength: integer|boolean, when `maxlength` is set true and the model attribute is validated by a string validator, the `maxlength` option will take the value of [[\yii\validators\StringValidator::max]]. This option is available since version 2.0.6. |
return | string | the generated textarea tag |
public static addCssStyle ( array &$options, string | array $style, boolean $overwrite = true ) | ||
$options | array | the HTML options to be modified. |
$style | string | array | the new style string (e.g. `'width: 100px; height: 200px'`) or array (e.g. `['width' => '100px', 'height' => '200px']`). |
$overwrite | boolean | whether to overwrite existing CSS properties if the new style contain them too. |
public static beginForm ( array | string $action = '', string $method = 'post', array $options = [] ) : string | ||
$action | array | string | the form action URL. This parameter will be processed by [[Url::to()]]. |
$method | string | the form submission method, such as "post", "get", "put", "delete" (case-insensitive). Since most browsers only support "post" and "get", if other methods are given, they will be simulated using "post", and a hidden input will be added which contains the actual method type. See [[\yii\web\Request::methodParam]] for more details. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. Special options: - `csrf`: whether to generate the CSRF hidden input. Defaults to true. |
return | string | the generated form start tag. |
public static beginTag ( string | boolean | null $name, array $options = [] ) : string | ||
$name | string | boolean | null | the tag name. If $name is `null` or `false`, the corresponding content will be rendered without any tag. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated start tag |
protected static booleanInput ( string $type, string $name, boolean $checked = false, array $options = [] ) : string | ||
$type | string | the input type. This can be either `radio` or `checkbox`. |
$name | string | the name attribute. |
$checked | boolean | whether the checkbox should be checked. |
$options | array | the tag options in terms of name-value pairs. The following options are specially handled: - uncheck: string, the value associated with the uncheck state of the checkbox. When this attribute is present, a hidden input will be generated so that if the checkbox is not checked and is submitted, the value of this attribute will still be submitted to the server via the hidden input. - label: string, a label displayed next to the checkbox. It will NOT be HTML-encoded. Therefore you can pass in HTML code such as an image tag. If this is is coming from end users, you should [[encode()]] it to prevent XSS attacks. When this option is specified, the checkbox will be enclosed by a label tag. - labelOptions: array, the HTML attributes for the label tag. Do not set this option unless you set the "label" option. The rest of the options will be rendered as the attributes of the resulting checkbox tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated checkbox tag |
public static button ( string $content = 'Button', array $options = [] ) : string | ||
$content | string | the content enclosed within the button tag. It will NOT be HTML-encoded. Therefore you can pass in HTML code such as an image tag. If this is is coming from end users, you should consider [[encode()]] it to prevent XSS attacks. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated button tag |
public static buttonInput ( string $label = 'Button', array $options = [] ) : string | ||
$label | string | the value attribute. If it is null, the value attribute will not be generated. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated button tag |
public static checkbox ( string $name, boolean $checked = false, array $options = [] ) : string | ||
$name | string | the name attribute. |
$checked | boolean | whether the checkbox should be checked. |
$options | array | the tag options in terms of name-value pairs. See [[booleanInput()]] for details about accepted attributes. |
return | string | the generated checkbox tag |
public static checkboxList ( string $name, string | array | null $selection = null, array $items = [], array $options = [] ) : string | ||
$name | string | the name attribute of each checkbox. |
$selection | string | array | null | the selected value(s). String for single or array for multiple selection(s). |
$items | array | the data item used to generate the checkboxes. The array keys are the checkbox values, while the array values are the corresponding labels. |
$options | array | options (name => config) for the checkbox list container tag. The following options are specially handled: - tag: string|false, the tag name of the container element. False to render checkbox without container. See also [[tag()]]. - unselect: string, the value that should be submitted when none of the checkboxes is selected. By setting this option, a hidden input will be generated. - encode: boolean, whether to HTML-encode the checkbox labels. Defaults to true. This option is ignored if `item` option is set. - separator: string, the HTML code that separates items. - itemOptions: array, the options for generating the checkbox tag using [[checkbox()]]. - item: callable, a callback that can be used to customize the generation of the HTML code corresponding to a single item in $items. The signature of this callback must be: ```php function ($index, $label, $name, $checked, $value) ``` where $index is the zero-based index of the checkbox in the whole list; $label is the label for the checkbox; and $name, $value and $checked represent the name, value and the checked status of the checkbox input, respectively. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated checkbox list |
public static csrfMetaTags ( ) : string | ||
return | string | the generated meta tags |
public static cssFile ( array | string $url, array $options = [] ) : string | ||
$url | array | string | the URL of the external CSS file. This parameter will be processed by [[Url::to()]]. |
$options | array | the tag options in terms of name-value pairs. The following options are specially handled: - condition: specifies the conditional comments for IE, e.g., `lt IE 9`. When this is specified, the generated `link` tag will be enclosed within the conditional comments. This is mainly useful for supporting old versions of IE browsers. - noscript: if set to true, `link` tag will be wrapped into ` |
return | string | the generated link tag |
public static cssStyleFromArray ( array $style ) : string | ||
$style | array | the CSS style array. The array keys are the CSS property names, and the array values are the corresponding CSS property values. |
return | string | the CSS style string. If the CSS style is empty, a null will be returned. |
public static cssStyleToArray ( string $style ) : array | ||
$style | string | the CSS style string |
return | array | the array representation of the CSS style |
public static dropDownList ( string $name, string | array | null $selection = null, array $items = [], array $options = [] ) : string | ||
$name | string | the input name |
$selection | string | array | null | the selected value(s). String for single or array for multiple selection(s). |
$items | array | the option data items. The array keys are option values, and the array values are the corresponding option labels. The array can also be nested (i.e. some array values are arrays too). For each sub-array, an option group will be generated whose label is the key associated with the sub-array. If you have a list of data models, you may convert them into the format described above using [[\yii\helpers\ArrayHelper::map()]]. Note, the values and labels will be automatically HTML-encoded by this method, and the blank spaces in the labels will also be HTML-encoded. |
$options | array | the tag options in terms of name-value pairs. The following options are specially handled: - prompt: string, a prompt text to be displayed as the first option. Since version 2.0.11 you can use an array to override the value and to set other tag attributes: ```php ['text' => 'Please select', 'options' => ['value' => 'none', 'class' => 'prompt', 'label' => 'Select']], ``` - options: array, the attributes for the select option tags. The array keys must be valid option values, and the array values are the extra attributes for the corresponding option tags. For example, ```php [ 'value1' => ['disabled' => true], 'value2' => ['label' => 'value 2'], ]; ``` - groups: array, the attributes for the optgroup tags. The structure of this is similar to that of 'options', except that the array keys represent the optgroup labels specified in $items. - encodeSpaces: bool, whether to encode spaces in option prompt and option value with ` ` character. Defaults to false. - encode: bool, whether to encode option prompt and option value characters. Defaults to `true`. This option is available since 2.0.3. The rest of the options will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated drop-down list tag |
public static error ( |
||
$model | the model object | |
$attribute | string | the attribute name or expression. See [[getAttributeName()]] for the format about attribute expression. |
$options | array | the tag options in terms of name-value pairs. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. The following options are specially handled: - tag: this specifies the tag name. If not set, "div" will be used. See also [[tag()]]. - encode: boolean, if set to false then the error message won't be encoded. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated label tag |
public static errorSummary ( |
||
$models | the model(s) whose validation errors are to be displayed. | |
$options | array | the tag options in terms of name-value pairs. The following options are specially handled: - header: string, the header HTML for the error summary. If not set, a default prompt string will be used. - footer: string, the footer HTML for the error summary. Defaults to empty string. - encode: boolean, if set to false then the error messages won't be encoded. Defaults to `true`. - showAllErrors: boolean, if set to true every error message for each attribute will be shown otherwise only the first error message for each attribute will be shown. Defaults to `false`. Option is available since 2.0.10. The rest of the options will be rendered as the attributes of the container tag. |
return | string | the generated error summary |
public static escapeJsRegularExpression ( string $regexp ) : string | ||
$regexp | string | the regular expression to be escaped. |
return | string | the escaped result. |
public static fileInput ( string $name, string $value = null, array $options = [] ) : string | ||
$name | string | the name attribute. |
$value | string | the value attribute. If it is null, the value attribute will not be generated. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated file input tag |
public static getAttributeName ( string $attribute ) : string | ||
$attribute | string | the attribute name or expression |
return | string | the attribute name without prefix and suffix. |
public static getInputId ( |
||
$model | the model object | |
$attribute | string | the attribute name or expression. See [[getAttributeName()]] for explanation of attribute expression. |
return | string | the generated input ID |
public static getInputName ( |
||
$model | the model object | |
$attribute | string | the attribute name or expression |
return | string | the generated input name |
public static img ( array | string $src, array $options = [] ) : string | ||
$src | array | string | the image URL. This parameter will be processed by [[Url::to()]]. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated image tag |
public static input ( string $type, string $name = null, string $value = null, array $options = [] ) : string | ||
$type | string | the type attribute. |
$name | string | the name attribute. If it is null, the name attribute will not be generated. |
$value | string | the value attribute. If it is null, the value attribute will not be generated. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated input tag |
public static jsFile ( string $url, array $options = [] ) : string | ||
$url | string | the URL of the external JavaScript file. This parameter will be processed by [[Url::to()]]. |
$options | array | the tag options in terms of name-value pairs. The following option is specially handled: - condition: specifies the conditional comments for IE, e.g., `lt IE 9`. When this is specified, the generated `script` tag will be enclosed within the conditional comments. This is mainly useful for supporting old versions of IE browsers. The rest of the options will be rendered as the attributes of the resulting script tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated script tag |
public static label ( string $content, string $for = null, array $options = [] ) : string | ||
$content | string | label text. It will NOT be HTML-encoded. Therefore you can pass in HTML code such as an image tag. If this is is coming from end users, you should [[encode()]] it to prevent XSS attacks. |
$for | string | the ID of the HTML element that this label is associated with. If this is null, the "for" attribute will not be generated. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated label tag |
public static listBox ( string $name, string | array | null $selection = null, array $items = [], array $options = [] ) : string | ||
$name | string | the input name |
$selection | string | array | null | the selected value(s). String for single or array for multiple selection(s). |
$items | array | the option data items. The array keys are option values, and the array values are the corresponding option labels. The array can also be nested (i.e. some array values are arrays too). For each sub-array, an option group will be generated whose label is the key associated with the sub-array. If you have a list of data models, you may convert them into the format described above using [[\yii\helpers\ArrayHelper::map()]]. Note, the values and labels will be automatically HTML-encoded by this method, and the blank spaces in the labels will also be HTML-encoded. |
$options | array | the tag options in terms of name-value pairs. The following options are specially handled: - prompt: string, a prompt text to be displayed as the first option. Since version 2.0.11 you can use an array to override the value and to set other tag attributes: ```php ['text' => 'Please select', 'options' => ['value' => 'none', 'class' => 'prompt', 'label' => 'Select']], ``` - options: array, the attributes for the select option tags. The array keys must be valid option values, and the array values are the extra attributes for the corresponding option tags. For example, ```php [ 'value1' => ['disabled' => true], 'value2' => ['label' => 'value 2'], ]; ``` - groups: array, the attributes for the optgroup tags. The structure of this is similar to that of 'options', except that the array keys represent the optgroup labels specified in $items. - unselect: string, the value that will be submitted when no option is selected. When this attribute is set, a hidden field will be generated so that if no option is selected in multiple mode, we can still obtain the posted unselect value. - encodeSpaces: bool, whether to encode spaces in option prompt and option value with ` ` character. Defaults to false. - encode: bool, whether to encode option prompt and option value characters. Defaults to `true`. This option is available since 2.0.3. The rest of the options will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated list box tag |
public static mailto ( string $text, string $email = null, array $options = [] ) : string | ||
$text | string | link body. It will NOT be HTML-encoded. Therefore you can pass in HTML code such as an image tag. If this is coming from end users, you should consider [[encode()]] it to prevent XSS attacks. |
string | email address. If this is null, the first parameter (link body) will be treated as the email address and used. | |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated mailto link |
public static ol ( array | Traversable $items, array $options = [] ) : string | ||
$items | array | Traversable | the items for generating the list. Each item generates a single list item. Note that items will be automatically HTML encoded if `$options['encode']` is not set or true. |
$options | array | options (name => config) for the radio button list. The following options are supported: - encode: boolean, whether to HTML-encode the items. Defaults to true. This option is ignored if the `item` option is specified. - itemOptions: array, the HTML attributes for the `li` tags. This option is ignored if the `item` option is specified. - item: callable, a callback that is used to generate each individual list item. The signature of this callback must be: ```php function ($item, $index) ``` where $index is the array key corresponding to `$item` in `$items`. The callback should return the whole list item tag. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated ordered list. An empty string is returned if `$items` is empty. |
public static passwordInput ( string $name, string $value = null, array $options = [] ) : string | ||
$name | string | the name attribute. |
$value | string | the value attribute. If it is null, the value attribute will not be generated. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated password input tag |
public static radio ( string $name, boolean $checked = false, array $options = [] ) : string | ||
$name | string | the name attribute. |
$checked | boolean | whether the radio button should be checked. |
$options | array | the tag options in terms of name-value pairs. See [[booleanInput()]] for details about accepted attributes. |
return | string | the generated radio button tag |
public static radioList ( string $name, string | array | null $selection = null, array $items = [], array $options = [] ) : string | ||
$name | string | the name attribute of each radio button. |
$selection | string | array | null | the selected value(s). String for single or array for multiple selection(s). |
$items | array | the data item used to generate the radio buttons. The array keys are the radio button values, while the array values are the corresponding labels. |
$options | array | options (name => config) for the radio button list container tag. The following options are specially handled: - tag: string|false, the tag name of the container element. False to render radio buttons without container. See also [[tag()]]. - unselect: string, the value that should be submitted when none of the radio buttons is selected. By setting this option, a hidden input will be generated. - encode: boolean, whether to HTML-encode the checkbox labels. Defaults to true. This option is ignored if `item` option is set. - separator: string, the HTML code that separates items. - itemOptions: array, the options for generating the radio button tag using [[radio()]]. - item: callable, a callback that can be used to customize the generation of the HTML code corresponding to a single item in $items. The signature of this callback must be: ```php function ($index, $label, $name, $checked, $value) ``` where $index is the zero-based index of the radio button in the whole list; $label is the label for the radio button; and $name, $value and $checked represent the name, value and the checked status of the radio button input, respectively. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated radio button list |
public static renderSelectOptions ( string | array | null $selection, array $items, array &$tagOptions = [] ) : string | ||
$selection | string | array | null | the selected value(s). String for single or array for multiple selection(s). |
$items | array | the option data items. The array keys are option values, and the array values are the corresponding option labels. The array can also be nested (i.e. some array values are arrays too). For each sub-array, an option group will be generated whose label is the key associated with the sub-array. If you have a list of data models, you may convert them into the format described above using [[\yii\helpers\ArrayHelper::map()]]. Note, the values and labels will be automatically HTML-encoded by this method, and the blank spaces in the labels will also be HTML-encoded. |
$tagOptions | array | the $options parameter that is passed to the [[dropDownList()]] or [[listBox()]] call. This method will take out these elements, if any: "prompt", "options" and "groups". See more details in [[dropDownList()]] for the explanation of these elements. |
return | string | the generated list options |
public static renderTagAttributes ( array $attributes ) : string | ||
$attributes | array | attributes to be rendered. The attribute values will be HTML-encoded using [[encode()]]. |
return | string | the rendering result. If the attributes are not empty, they will be rendered into a string with a leading white space (so that it can be directly appended to the tag name in a tag. If there is no attribute, an empty string will be returned. |
public static resetButton ( string $content = 'Reset', array $options = [] ) : string | ||
$content | string | the content enclosed within the button tag. It will NOT be HTML-encoded. Therefore you can pass in HTML code such as an image tag. If this is is coming from end users, you should consider [[encode()]] it to prevent XSS attacks. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated reset button tag |
public static resetInput ( string $label = 'Reset', array $options = [] ) : string | ||
$label | string | the value attribute. If it is null, the value attribute will not be generated. |
$options | array | the attributes of the button tag. The values will be HTML-encoded using [[encode()]]. Attributes whose value is null will be ignored and not put in the tag returned. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated button tag |
public static script ( string $content, array $options = [] ) : string | ||
$content | string | the script content |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated script tag |
public static style ( string $content, array $options = [] ) : string | ||
$content | string | the style content |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated style tag |
public static submitButton ( string $content = 'Submit', array $options = [] ) : string | ||
$content | string | the content enclosed within the button tag. It will NOT be HTML-encoded. Therefore you can pass in HTML code such as an image tag. If this is is coming from end users, you should consider [[encode()]] it to prevent XSS attacks. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated submit button tag |
public static submitInput ( string $label = 'Submit', array $options = [] ) : string | ||
$label | string | the value attribute. If it is null, the value attribute will not be generated. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated button tag |
public static tag ( string | boolean | null $name, string $content = '', array $options = [] ) : string | ||
$name | string | boolean | null | the tag name. If $name is `null` or `false`, the corresponding content will be rendered without any tag. |
$content | string | the content to be enclosed between the start and end tags. It will not be HTML-encoded. If this is coming from end users, you should consider [[encode()]] it to prevent XSS attacks. |
$options | array | the HTML tag attributes (HTML options) in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. For example when using `['class' => 'my-class', 'target' => '_blank', 'value' => null]` it will result in the html attributes rendered like this: `class="my-class" target="_blank"`. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated HTML tag |
public static textInput ( string $name, string $value = null, array $options = [] ) : string | ||
$name | string | the name attribute. |
$value | string | the value attribute. If it is null, the value attribute will not be generated. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated text input tag |
public static textarea ( string $name, string $value = '', array $options = [] ) : string | ||
$name | string | the input name |
$value | string | the input value. Note that it will be encoded using [[encode()]]. |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. The following special options are recognized: - `doubleEncode`: whether to double encode HTML entities in `$value`. If `false`, HTML entities in `$value` will not be further encoded. This option is available since version 2.0.11. |
return | string | the generated text area tag |
public static ul ( array | Traversable $items, array $options = [] ) : string | ||
$items | array | Traversable | the items for generating the list. Each item generates a single list item. Note that items will be automatically HTML encoded if `$options['encode']` is not set or true. |
$options | array | options (name => config) for the radio button list. The following options are supported: - encode: boolean, whether to HTML-encode the items. Defaults to true. This option is ignored if the `item` option is specified. - separator: string, the HTML code that separates items. Defaults to a simple newline (`"\n"`). This option is available since version 2.0.7. - itemOptions: array, the HTML attributes for the `li` tags. This option is ignored if the `item` option is specified. - item: callable, a callback that is used to generate each individual list item. The signature of this callback must be: ```php function ($item, $index) ``` where $index is the array key corresponding to `$item` in `$items`. The callback should return the whole list item tag. See [[renderTagAttributes()]] for details on how attributes are being rendered. |
return | string | the generated unordered list. An empty list tag will be returned if `$items` is empty. |
public static $attributeOrder |
public static $dataAttributes |