Html

Type
Class
Namespace
craft\helpers
Inherits
craft\helpers\Html » yii\helpers\Html » yii\helpers\BaseHtml
Since
3.0

Class Html

View source

Public Properties

PropertyDescription
$attributeOrderarray – The preferred order of attributes in a tag.
$attributeRegexstring – Regular expression used for attribute name validation.
$dataAttributesarray – List of tag attributes that should be specially handled when their values are of array type.
$voidElementsarray – List of void elements (element name => 1)

Public Methods

MethodDescription
a()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()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()Adds a CSS class (or several classes) to the specified options.
addCssStyle()Adds the specified CSS style to the HTML options.
beginForm()Generates a form start tag.
beginTag()Generates a start tag.
button()Generates a button tag.
buttonInput()Generates an input button.
checkbox()Generates a checkbox input.
checkboxList()Generates a list of checkboxes.
csrfMetaTags()Generates the meta tags containing CSRF token information.
cssFile()Generates a link tag that refers to an external CSS file.
cssStyleFromArray()Converts a CSS style array into a string representation.
cssStyleToArray()Converts a CSS style string into an array representation.
decode()Decodes special HTML entities back to the corresponding characters.
dropDownList()Generates a drop-down list.
encode()Encodes special characters into HTML entities.
encodeParams()Will take an HTML string and an associative array of key=>value pairs, HTML encode the values and swap them back into the original string using the keys as tokens.
endForm()Generates a form end tag.
endTag()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()Escapes regular expression to use in JavaScript.
fileInput()Generates a file input field.
getAttributeName()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()Generates a hidden input field.
img()Generates an image tag.
input()Generates an input type of the given type.
jsFile()Generates a script tag that refers to an external JavaScript file.
label()Generates a label tag.
listBox()Generates a list box.
mailto()Generates a mailto hyperlink.
ol()Generates an ordered list.
passwordInput()Generates a password input field.
radio()Generates a radio button input.
radioList()Generates a list of radio buttons.
removeCssClass()Removes a CSS class from the specified options.
removeCssStyle()Removes the specified CSS style from the HTML options.
renderSelectOptions()Renders the option tags that can be used by dropDownList() and listBox().
renderTagAttributes()Renders the HTML tag attributes.
resetButton()Generates a reset button tag.
resetInput()Generates a reset input button.
script()Generates a script tag.
style()Generates a style tag.
submitButton()Generates a submit button tag.
submitInput()Generates a submit input button.
tag()Generates a complete HTML tag.
textInput()Generates a text input field.
textarea()Generates a text area input.
ul()Generates an unordered list.

encodeParams()

Will take an HTML string and an associative array of key=>value pairs, HTML encode the values and swap them back into the original string using the keys as tokens.

View source

Arguments

  • $html (string) – The HTML string.
  • $variables (array) – An associative array of key => value pairs to be applied to the HTML string using strtr.

Returns

string – The HTML string with the encoded variable values swapped in.

Signature

public static string encodeParams ( \craft\helpers\string $html, array $variables = [] )

Protected Methods

MethodDescription
activeBooleanInput()Generates a boolean input This method is mainly called by activeCheckbox() and activeRadio().
activeListInput()Generates a list of input fields.
booleanInput()Generates a boolean input.
setActivePlaceholder()Generate placeholder from model attribute label.