PHP Класс yii\helpers\BaseHtml

Do not use BaseHtml. Use [[Html]] instead.
С версии: 2.0
Автор: Qiang Xue ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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)

Открытые методы

Метод Описание
a ( string $text, array | string | null $url = null, array $options = [] ) : string Generates a hyperlink tag.
activeCheckbox ( Model $model, string $attribute, array $options = [] ) : string Generates a checkbox tag together with a label for the given model attribute.
activeCheckboxList ( Model $model, string $attribute, array $items, array $options = [] ) : string Generates a list of checkboxes.
activeDropDownList ( Model $model, string $attribute, array $items, array $options = [] ) : string Generates a drop-down list for the given model attribute.
activeFileInput ( Model $model, string $attribute, array $options = [] ) : string Generates a file input tag for the given model attribute.
activeHiddenInput ( Model $model, string $attribute, array $options = [] ) : string Generates a hidden input tag for the given model attribute.
activeHint ( Model $model, string $attribute, array $options = [] ) : string Generates a hint tag for the given model attribute.
activeInput ( string $type, Model $model, string $attribute, array $options = [] ) : string Generates an input tag for the given model attribute.
activeLabel ( Model $model, string $attribute, array $options = [] ) : string Generates a label tag for the given model attribute.
activeListBox ( Model $model, string $attribute, array $items, array $options = [] ) : string Generates a list box.
activePasswordInput ( Model $model, string $attribute, array $options = [] ) : string Generates a password input tag for the given model attribute.
activeRadio ( Model $model, string $attribute, array $options = [] ) : string Generates a radio button tag together with a label for the given model attribute.
activeRadioList ( Model $model, string $attribute, array $items, array $options = [] ) : string Generates a list of radio buttons.
activeTextInput ( Model $model, string $attribute, array $options = [] ) : string Generates a text input tag for the given model attribute.
activeTextarea ( Model $model, string $attribute, array $options = [] ) : string 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 ( Model $model, string $attribute, array $options = [] ) : string Generates a tag that contains the first validation error of the specified model attribute.
errorSummary ( Model | Model[] $models, array $options = [] ) : string 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 ( Model $model, string $attribute ) : string | array Returns the value of the specified attribute name or expression.
getInputId ( Model $model, string $attribute ) : string Generates an appropriate input ID for the specified attribute name or expression.
getInputName ( Model $model, string $attribute ) : string 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.

Защищенные методы

Метод Описание
activeBooleanInput ( string $type, Model $model, string $attribute, array $options = [] ) : string Generates a boolean input This method is mainly called by BaseHtml::activeCheckbox and BaseHtml::activeRadio.
activeListInput ( string $type, Model $model, string $attribute, array $items, array $options = [] ) : string Generates a list of input fields.
booleanInput ( string $type, string $name, boolean $checked = false, array $options = [] ) : string Generates a boolean input.

Приватные методы

Метод Описание
mergeCssClasses ( array $existingClasses, array $additionalClasses ) : array Merges already existing CSS classes with new one.
normalizeMaxLength ( Model $model, string $attribute, array &$options ) 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.

Описание методов

a() публичный статический Метод

Generates a hyperlink tag.
См. также: yii\helpers\Url::to()
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.
Результат string the generated hyperlink

activeBooleanInput() защищенный статический Метод

Generates a boolean input This method is mainly called by BaseHtml::activeCheckbox and BaseHtml::activeRadio.
С версии: 2.0.9
protected static activeBooleanInput ( string $type, Model $model, string $attribute, array $options = [] ) : string
$type string the input type. This can be either `radio` or `checkbox`.
$model yii\base\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.
Результат string the generated input element

activeCheckbox() публичный статический Метод

This method will generate the "checked" tag attribute according to the model attribute value.
public static activeCheckbox ( Model $model, string $attribute, array $options = [] ) : string
$model yii\base\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.
Результат string the generated checkbox tag

activeCheckboxList() публичный статический Метод

A checkbox list allows multiple selection, like BaseHtml::listBox. As a result, the corresponding submitted value is an array. The selection of the checkbox list is taken from the value of the model attribute.
public static activeCheckboxList ( Model $model, string $attribute, array $items, array $options = [] ) : string
$model yii\base\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.
Результат string the generated checkbox list

activeDropDownList() публичный статический Метод

The selection of the drop-down list is taken from the value of the model attribute.
public static activeDropDownList ( Model $model, string $attribute, array $items, array $options = [] ) : string
$model yii\base\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.
Результат string the generated drop-down list tag

activeFileInput() публичный статический Метод

This method will generate the "name" and "value" tag attributes automatically for the model attribute unless they are explicitly specified in $options.
public static activeFileInput ( Model $model, string $attribute, array $options = [] ) : string
$model yii\base\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.
Результат string the generated input tag

activeHiddenInput() публичный статический Метод

This method will generate the "name" and "value" tag attributes automatically for the model attribute unless they are explicitly specified in $options.
public static activeHiddenInput ( Model $model, string $attribute, array $options = [] ) : string
$model yii\base\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.
Результат string the generated input tag

activeHint() публичный статический Метод

The hint text is the hint associated with the attribute, obtained via [[Model::getAttributeHint()]]. If no hint content can be obtained, method will return an empty string.
С версии: 2.0.4
public static activeHint ( Model $model, string $attribute, array $options = [] ) : string
$model yii\base\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.
Результат string the generated hint tag

activeInput() публичный статический Метод

This method will generate the "name" and "value" tag attributes automatically for the model attribute unless they are explicitly specified in $options.
public static activeInput ( string $type, Model $model, string $attribute, array $options = [] ) : string
$type string the input type (e.g. 'text', 'password')
$model yii\base\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.
Результат string the generated input tag

activeLabel() публичный статический Метод

The label text is the label associated with the attribute, obtained via [[Model::getAttributeLabel()]].
public static activeLabel ( Model $model, string $attribute, array $options = [] ) : string
$model yii\base\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.
Результат string the generated label tag

activeListBox() публичный статический Метод

The selection of the list box is taken from the value of the model attribute.
public static activeListBox ( Model $model, string $attribute, array $items, array $options = [] ) : string
$model yii\base\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.
Результат string the generated list box tag

activeListInput() защищенный статический Метод

protected static activeListInput ( string $type, Model $model, string $attribute, array $items, array $options = [] ) : string
$type string the input type. This can be 'listBox', 'radioList', or 'checkBoxList'.
$model yii\base\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`.
Результат string the generated input list

activePasswordInput() публичный статический Метод

This method will generate the "name" and "value" tag attributes automatically for the model attribute unless they are explicitly specified in $options.
public static activePasswordInput ( Model $model, string $attribute, array $options = [] ) : string
$model yii\base\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.
Результат string the generated input tag

activeRadio() публичный статический Метод

This method will generate the "checked" tag attribute according to the model attribute value.
public static activeRadio ( Model $model, string $attribute, array $options = [] ) : string
$model yii\base\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.
Результат string the generated radio button tag

activeRadioList() публичный статический Метод

A radio button list is like a checkbox list, except that it only allows single selection. The selection of the radio buttons is taken from the value of the model attribute.
public static activeRadioList ( Model $model, string $attribute, array $items, array $options = [] ) : string
$model yii\base\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.
Результат string the generated radio button list

activeTextInput() публичный статический Метод

This method will generate the "name" and "value" tag attributes automatically for the model attribute unless they are explicitly specified in $options.
public static activeTextInput ( Model $model, string $attribute, array $options = [] ) : string
$model yii\base\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.
Результат string the generated input tag

activeTextarea() публичный статический Метод

The model attribute value will be used as the content in the textarea.
public static activeTextarea ( Model $model, string $attribute, array $options = [] ) : string
$model yii\base\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.
Результат string the generated textarea tag

addCssClass() публичный статический Метод

If the CSS class is already in the options, it will not be added again. If class specification at given options is an array, and some class placed there with the named (string) key, overriding of such key will have no effect. For example: php $options = ['class' => ['persistent' => 'initial']]; Html::addCssClass($options, ['persistent' => 'override']); var_dump($options['class']); // outputs: array('persistent' => 'initial');
public static addCssClass ( array &$options, string | array $class )
$options array the options to be modified.
$class string | array the CSS class(es) to be added

addCssStyle() публичный статический Метод

If the options already contain a style element, the new style will be merged with the existing one. If a CSS property exists in both the new and the old styles, the old one may be overwritten if $overwrite is true. For example, php Html::addCssStyle($options, 'width: 100px; height: 200px');
См. также: removeCssStyle()
См. также: cssStyleFromArray()
См. также: cssStyleToArray()
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.

beginForm() публичный статический Метод

Generates a form start tag.
См. также: endForm()
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.
Результат string the generated form start tag.

beginTag() публичный статический Метод

Generates a start tag.
См. также: endTag()
См. также: 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.
Результат string the generated start tag

booleanInput() защищенный статический Метод

Generates a boolean input.
С версии: 2.0.9
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.
Результат string the generated checkbox tag

button() публичный статический Метод

Generates a button 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.
Результат string the generated button tag

buttonInput() публичный статический Метод

Generates an input button.
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.
Результат string the generated button tag

checkbox() публичный статический Метод

Generates a checkbox input.
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.
Результат string the generated checkbox tag

checkboxList() публичный статический Метод

A checkbox list allows multiple selection, like BaseHtml::listBox. As a result, the corresponding submitted value is an array.
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.
Результат string the generated checkbox list

csrfMetaTags() публичный статический Метод

Generates the meta tags containing CSRF token information.
См. также: Request::enableCsrfValidation
public static csrfMetaTags ( ) : string
Результат string the generated meta tags

cssFile() публичный статический Метод

Generates a link tag that refers to an external CSS file.
См. также: Url::to()
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 `
Результат string the generated link tag

cssStyleFromArray() публичный статический Метод

For example, php print_r(Html::cssStyleFromArray(['width' => '100px', 'height' => '200px'])); will display: 'width: 100px; height: 200px;'
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.
Результат string the CSS style string. If the CSS style is empty, a null will be returned.

cssStyleToArray() публичный статический Метод

The array keys are the CSS property names, and the array values are the corresponding CSS property values. For example, php print_r(Html::cssStyleToArray('width: 100px; height: 200px;')); will display: ['width' => '100px', 'height' => '200px']
public static cssStyleToArray ( string $style ) : array
$style string the CSS style string
Результат array the array representation of the CSS style

decode() публичный статический Метод

This is the opposite of BaseHtml::encode.
См. также: encode()
См. также: http://www.php.net/manual/en/function.htmlspecialchars-decode.php
public static decode ( string $content ) : string
$content string the content to be decoded
Результат string the decoded content

dropDownList() публичный статический Метод

Generates a drop-down list.
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.
Результат string the generated drop-down list tag

encode() публичный статический Метод

The [[\yii\base\Application::charset|application charset]] will be used for encoding.
См. также: decode()
См. также: http://www.php.net/manual/en/function.htmlspecialchars.php
public static encode ( string $content, boolean $doubleEncode = true ) : string
$content string the content to be encoded
$doubleEncode boolean whether to encode HTML entities in `$content`. If false, HTML entities in `$content` will not be further encoded.
Результат string the encoded content

endForm() публичный статический Метод

Generates a form end tag.
См. также: beginForm()
public static endForm ( ) : string
Результат string the generated tag

endTag() публичный статический Метод

Generates an end tag.
См. также: beginTag()
См. также: tag()
public static endTag ( string | boolean | null $name ) : string
$name string | boolean | null the tag name. If $name is `null` or `false`, the corresponding content will be rendered without any tag.
Результат string the generated end tag

error() публичный статический Метод

Note that even if there is no validation error, this method will still return an empty error tag.
public static error ( Model $model, string $attribute, array $options = [] ) : string
$model yii\base\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.
Результат string the generated label tag

errorSummary() публичный статический Метод

If there is no validation error, an empty error summary markup will still be generated, but it will be hidden.
public static errorSummary ( Model | Model[] $models, array $options = [] ) : string
$models yii\base\Model | yii\base\Model[] 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.
Результат string the generated error summary

escapeJsRegularExpression() публичный статический Метод

Escapes regular expression to use in JavaScript
С версии: 2.0.6
public static escapeJsRegularExpression ( string $regexp ) : string
$regexp string the regular expression to be escaped.
Результат string the escaped result.

fileInput() публичный статический Метод

To use a file input field, you should set the enclosing form's "enctype" attribute to be "multipart/form-data". After the form is submitted, the uploaded file information can be obtained via $_FILES[$name] (see PHP documentation).
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.
Результат string the generated file input tag

getAttributeName() публичный статический Метод

An attribute expression is an attribute name prefixed and/or suffixed with array indexes. It is mainly used in tabular data input and/or input of array type. Below are some examples: - [0]content is used in tabular data input to represent the "content" attribute for the first model in tabular input; - dates[0] represents the first array element of the "dates" attribute; - [0]dates[0] represents the first array element of the "dates" attribute for the first model in tabular input. If $attribute has neither prefix nor suffix, it will be returned back without change.
public static getAttributeName ( string $attribute ) : string
$attribute string the attribute name or expression
Результат string the attribute name without prefix and suffix.

getAttributeValue() публичный статический Метод

For an attribute expression like [0]dates[0], this method will return the value of $model->dates[0]. See BaseHtml::getAttributeName for more details about attribute expression. If an attribute value is an instance of [[ActiveRecordInterface]] or an array of such instances, the primary value(s) of the AR instance(s) will be returned instead.
public static getAttributeValue ( Model $model, string $attribute ) : string | array
$model yii\base\Model the model object
$attribute string the attribute name or expression
Результат string | array the corresponding attribute value

getInputId() публичный статический Метод

This method converts the result BaseHtml::getInputName into a valid input ID. For example, if BaseHtml::getInputName returns Post[content], this method will return post-content.
public static getInputId ( Model $model, string $attribute ) : string
$model yii\base\Model the model object
$attribute string the attribute name or expression. See [[getAttributeName()]] for explanation of attribute expression.
Результат string the generated input ID

getInputName() публичный статический Метод

This method generates a name that can be used as the input name to collect user input for the specified attribute. The name is generated according to the [[Model::formName|form name]] of the model and the given attribute name. For example, if the form name of the Post model is Post, then the input name generated for the content attribute would be Post[content]. See BaseHtml::getAttributeName for explanation of attribute expression.
public static getInputName ( Model $model, string $attribute ) : string
$model yii\base\Model the model object
$attribute string the attribute name or expression
Результат string the generated input name

hiddenInput() публичный статический Метод

Generates a hidden input field.
public static hiddenInput ( 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.
Результат string the generated hidden input tag

img() публичный статический Метод

Generates an image tag.
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.
Результат string the generated image tag

input() публичный статический Метод

Generates an input type of the given type.
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.
Результат string the generated input tag

jsFile() публичный статический Метод

Generates a script tag that refers to an external JavaScript file.
См. также: Url::to()
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.
Результат string the generated script tag

label() публичный статический Метод

Generates a label 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.
Результат string the generated label tag

listBox() публичный статический Метод

Generates a list box.
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.
Результат string the generated list box tag

mailto() публичный статический Метод

Generates a mailto hyperlink.
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.
$email 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.
Результат string the generated mailto link

ol() публичный статический Метод

Generates an ordered list.
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.
Результат string the generated ordered list. An empty string is returned if `$items` is empty.

passwordInput() публичный статический Метод

Generates a password input field.
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.
Результат string the generated password input tag

radio() публичный статический Метод

Generates a radio button input.
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.
Результат string the generated radio button tag

radioList() публичный статический Метод

A radio button list is like a checkbox list, except that it only allows single selection.
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.
Результат string the generated radio button list

removeCssClass() публичный статический Метод

Removes a CSS class from the specified options.
public static removeCssClass ( array &$options, string | array $class )
$options array the options to be modified.
$class string | array the CSS class(es) to be removed

removeCssStyle() публичный статический Метод

For example, php Html::removeCssStyle($options, ['width', 'height']);
См. также: addCssStyle()
public static removeCssStyle ( array &$options, string | array $properties )
$options array the HTML options to be modified.
$properties string | array the CSS properties to be removed. You may use a string if you are removing a single property.

renderSelectOptions() публичный статический Метод

Renders the option tags that can be used by BaseHtml::dropDownList and BaseHtml::listBox.
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.
Результат string the generated list options

renderTagAttributes() публичный статический Метод

Attributes whose values are of boolean type will be treated as boolean attributes. Attributes whose values are null will not be rendered. The values of attributes will be HTML-encoded using BaseHtml::encode. The "data" attribute is specially handled when it is receiving an array value. In this case, the array will be "expanded" and a list data attributes will be rendered. For example, if 'data' => ['id' => 1, 'name' => 'yii'], then this will be rendered: data-id="1" data-name="yii". Additionally 'data' => ['params' => ['id' => 1, 'name' => 'yii'], 'status' => 'ok'] will be rendered as: data-params='{"id":1,"name":"yii"}' data-status="ok".
public static renderTagAttributes ( array $attributes ) : string
$attributes array attributes to be rendered. The attribute values will be HTML-encoded using [[encode()]].
Результат 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.

resetButton() публичный статический Метод

Generates a reset button tag.
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.
Результат string the generated reset button tag

resetInput() публичный статический Метод

Generates a reset input button.
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.
Результат string the generated button tag

script() публичный статический Метод

Generates a script 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.
Результат string the generated script tag

style() публичный статический Метод

Generates a style 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.
Результат string the generated style tag

submitButton() публичный статический Метод

Be careful when naming form elements such as submit buttons. According to the jQuery documentation there are some reserved names that can cause conflicts, e.g. submit, length, or method.
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.
Результат string the generated submit button tag

submitInput() публичный статический Метод

Be careful when naming form elements such as submit buttons. According to the jQuery documentation there are some reserved names that can cause conflicts, e.g. submit, length, or method.
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.
Результат string the generated button tag

tag() публичный статический Метод

Generates a complete HTML tag.
См. также: beginTag()
См. также: endTag()
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.
Результат string the generated HTML tag

textInput() публичный статический Метод

Generates a text input field.
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.
Результат string the generated text input tag

textarea() публичный статический Метод

Generates a text area input.
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.
Результат string the generated text area tag

ul() публичный статический Метод

Generates an unordered list.
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.
Результат string the generated unordered list. An empty list tag will be returned if `$items` is empty.

Описание свойств

$attributeOrder публичное статическое свойство

the preferred order of attributes in a tag. This mainly affects the order of the attributes that are rendered by BaseHtml::renderTagAttributes.
public static $attributeOrder

$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".
С версии: 2.0.3
public static $dataAttributes

$voidElements публичное статическое свойство

list of void elements (element name => 1)
См. также: http://www.w3.org/TR/html-markup/syntax.html#void-element
public static $voidElements