Class kartik\helpers\Html
Inheritance | kartik\helpers\Html » yii\helpers\Html » yii\helpers\BaseHtml |
---|---|
Available since version | 2.0 |
Html provides a set of static methods for generating commonly used HTML tags and extends yii\helpers\Html with additional bootstrap styled components and markup.
Nearly all of the methods in this class allow setting additional html attributes for the html
tags they generate. You can specify for example. 'class', 'style' or 'id' for an html element
using the $options
parameter. See the documentation of the tag() method for more details.
For example,
use kartik\helpers\Html;
echo Html::checkboxButtonGroup('cbx', [1, 2], [1 => 'Check 1', 2 => 'Check 2', 3 => 'Check 3']);
See also:
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$attributeOrder | array | The preferred order of attributes in a tag. | yii\helpers\BaseHtml |
$attributeRegex | string | Regular expression used for attribute name validation. | yii\helpers\BaseHtml |
$dataAttributes | array | List of tag attributes that should be specially handled when their values are of array type. | yii\helpers\BaseHtml |
$normalizeClassAttribute | boolean | Whether to removes duplicate class names in tag attribute class |
yii\helpers\BaseHtml |
$voidElements | array | List of void elements (element name => 1) | yii\helpers\BaseHtml |
Public Methods
Method | Description | Defined By |
---|---|---|
a() | Generates a hyperlink tag. | yii\helpers\BaseHtml |
abbr() | Generates a bootstrap abbreviation. | kartik\helpers\Html |
activeCheckbox() | Generates a checkbox tag together with a label for the given model attribute. | yii\helpers\BaseHtml |
activeCheckboxButtonGroup() | Generates an active bootstrap checkbox button group. A checkbox button group allows multiple selection, like listBox(). As a result, the corresponding submitted value is an array. The selection of the checkbox button group is taken from the value of the model attribute. | kartik\helpers\Html |
activeCheckboxList() | Generates a list of checkboxes. | yii\helpers\BaseHtml |
activeDropDownList() | Generates a drop-down list for the given model attribute. | yii\helpers\BaseHtml |
activeFileInput() | Generates a file input tag for the given model attribute. | yii\helpers\BaseHtml |
activeHiddenInput() | Generates a hidden input tag for the given model attribute. | yii\helpers\BaseHtml |
activeHint() | Generates a hint tag for the given model attribute. | yii\helpers\BaseHtml |
activeInput() | Generates an input tag for the given model attribute. | yii\helpers\BaseHtml |
activeLabel() | Generates a label tag for the given model attribute. | yii\helpers\BaseHtml |
activeListBox() | Generates a list box. | yii\helpers\BaseHtml |
activePasswordInput() | Generates a password input tag for the given model attribute. | yii\helpers\BaseHtml |
activeRadio() | Generates a radio button tag together with a label for the given model attribute. | yii\helpers\BaseHtml |
activeRadioButtonGroup() | Generates an active bootstrap radio button group. A radio button group is like a checkbox button group, except that it only allows single selection. The selection of the radio buttons is taken from the value of the model attribute. | kartik\helpers\Html |
activeRadioList() | Generates a list of radio buttons. | yii\helpers\BaseHtml |
activeTextInput() | Generates a text input tag for the given model attribute. | yii\helpers\BaseHtml |
activeTextarea() | Generates a textarea tag for the given model attribute. | yii\helpers\BaseHtml |
addCssClass() | Adds a CSS class (or several classes) to the specified options. | yii\helpers\BaseHtml |
addCssStyle() | Adds the specified CSS style to the HTML options. | yii\helpers\BaseHtml |
address() | Generates a bootstrap address block. | kartik\helpers\Html |
badge() | Generates a badge. | kartik\helpers\Html |
beginForm() | Generates a form start tag. | yii\helpers\BaseHtml |
beginTag() | Generates a start tag. | yii\helpers\BaseHtml |
blockquote() | Generates a bootstrap blockquote. | kartik\helpers\Html |
bsLabel() | Generates a bootstrap label markup. | kartik\helpers\Html |
button() | Generates a button tag. | yii\helpers\BaseHtml |
buttonInput() | Generates an input button. | yii\helpers\BaseHtml |
caret() | Generates a bootstrap caret. | kartik\helpers\Html |
checkbox() | Generates a checkbox input. | yii\helpers\BaseHtml |
checkboxButtonGroup() | Generates a bootstrap checkbox button group. A checkbox button group allows multiple selection, like listBox(). As a result, the corresponding submitted value is an array. | kartik\helpers\Html |
checkboxList() | Generates a list of checkboxes. | yii\helpers\BaseHtml |
closeButton() | Generates a generic bootstrap close icon button for dismissing content like modals and alerts. | kartik\helpers\Html |
csrfMetaTags() | Generates the meta tags containing CSRF token information. | yii\helpers\BaseHtml |
cssFile() | Generates a link tag that refers to an external CSS file. | yii\helpers\BaseHtml |
cssStyleFromArray() | Converts a CSS style array into a string representation. | yii\helpers\BaseHtml |
cssStyleToArray() | Converts a CSS style string into an array representation. | yii\helpers\BaseHtml |
decode() | Decodes special HTML entities back to the corresponding characters. | yii\helpers\BaseHtml |
dropDownList() | Generates a drop-down list. | yii\helpers\BaseHtml |
encode() | Encodes special characters into HTML entities. | yii\helpers\BaseHtml |
endForm() | Generates a form end tag. | yii\helpers\BaseHtml |
endTag() | Generates an end tag. | yii\helpers\BaseHtml |
error() | Generates a tag that contains the first validation error of the specified model attribute. | yii\helpers\BaseHtml |
errorSummary() | Generates a summary of the validation errors. | yii\helpers\BaseHtml |
escapeJsRegularExpression() | Escapes regular expression to use in JavaScript. | yii\helpers\BaseHtml |
fileInput() | Generates a file input field. | yii\helpers\BaseHtml |
getAttributeName() | Returns the real attribute name from the given attribute expression. | yii\helpers\BaseHtml |
getAttributeValue() | Returns the value of the specified attribute name or expression. | yii\helpers\BaseHtml |
getButtonGroup() | Generates a bootstrap toggle button group (checkbox or radio type) | kartik\helpers\Html |
getInputId() | Generates an appropriate input ID for the specified attribute name or expression. | yii\helpers\BaseHtml |
getInputIdByName() | Converts input name to ID. | yii\helpers\BaseHtml |
getInputName() | Generates an appropriate input name for the specified attribute name or expression. | yii\helpers\BaseHtml |
icon() | Generates a bootstrap icon markup. | kartik\helpers\Html |
img() | Generates an image tag. | yii\helpers\BaseHtml |
input() | Generates an input type of the given type. | yii\helpers\BaseHtml |
jsFile() | Generates a script tag that refers to an external JavaScript file. | yii\helpers\BaseHtml |
jumbotron() | Generates a jumbotron - a lightweight, flexible component that can optionally extend the entire viewport to showcase key content on your site. | kartik\helpers\Html |
label() | Generates a label tag. | yii\helpers\BaseHtml |
listBox() | Generates a list box. | yii\helpers\BaseHtml |
listGroup() | Generates a list group. Flexible and powerful component for displaying not only simple lists of elements, but complex ones with custom content. | kartik\helpers\Html |
mailto() | Generates a mailto hyperlink. | yii\helpers\BaseHtml |
media() | Generates a bootstrap media object. Abstract object styles for building various types of components (like blog comments, Tweets, etc) that feature a left-aligned or right-aligned image alongside textual content. | kartik\helpers\Html |
mediaList() | Generates bootstrap list of media (useful for comment threads or articles lists). | kartik\helpers\Html |
ol() | Generates an ordered list. | yii\helpers\BaseHtml |
pageHeader() | Generates a page header. | kartik\helpers\Html |
panel() | Generates a panel for boxing content. | kartik\helpers\Html |
passwordInput() | Generates a password input field. | yii\helpers\BaseHtml |
radio() | Generates a radio button input. | yii\helpers\BaseHtml |
radioButtonGroup() | Generates a bootstrap radio button group. A radio button group is like a checkbox button group, except that it only allows single selection. | kartik\helpers\Html |
radioList() | Generates a list of radio buttons. | yii\helpers\BaseHtml |
removeCssClass() | Removes a CSS class from the specified options. | yii\helpers\BaseHtml |
removeCssStyle() | Removes the specified CSS style from the HTML options. | yii\helpers\BaseHtml |
renderSelectOptions() | Renders the option tags that can be used by dropDownList() and listBox(). | yii\helpers\BaseHtml |
renderTagAttributes() | Renders the HTML tag attributes. | yii\helpers\BaseHtml |
resetButton() | Generates a reset button tag. | yii\helpers\BaseHtml |
resetInput() | Generates a reset input button. | yii\helpers\BaseHtml |
script() | Generates a script tag. | yii\helpers\BaseHtml |
style() | Generates a style tag. | yii\helpers\BaseHtml |
submitButton() | Generates a submit button tag. | yii\helpers\BaseHtml |
submitInput() | Generates a submit input button. | yii\helpers\BaseHtml |
tag() | Generates a complete HTML tag. | yii\helpers\BaseHtml |
textInput() | Generates a text input field. | yii\helpers\BaseHtml |
textarea() | Generates a text area input. | yii\helpers\BaseHtml |
ul() | Generates an unordered list. | yii\helpers\BaseHtml |
well() | Generates a well container. | kartik\helpers\Html |
Protected Methods
Method | Description | Defined By |
---|---|---|
activeBooleanInput() | Generates a boolean input This method is mainly called by activeCheckbox() and activeRadio(). | yii\helpers\BaseHtml |
activeListInput() | Generates a list of input fields. | yii\helpers\BaseHtml |
booleanInput() | Generates a boolean input. | yii\helpers\BaseHtml |
getListGroupItem() | Processes and generates each list group item | kartik\helpers\Html |
getMediaItem() | Processes and generates each media item | kartik\helpers\Html |
getMediaList() | Processes media items array to generate a recursive list. | kartik\helpers\Html |
getPanelContent() | Generates panel content | kartik\helpers\Html |
getPanelTitle() | Generates panel title for heading and footer. | kartik\helpers\Html |
hasCssClass() | Check if HTML options has specified CSS class | kartik\helpers\Html |
setActivePlaceholder() | Generate placeholder from model attribute label. | yii\helpers\BaseHtml |
Constants
Constant | Value | Description | Defined By |
---|---|---|---|
CLEAR_FLOAT | 'clearfix' | Bootstrap clear floats CSS | kartik\helpers\Html |
FLOAT_CENTER | 'center-block' | Bootstrap centered block CSS | kartik\helpers\Html |
FLOAT_LEFT | 'pull-left' | Bootstrap float left CSS | kartik\helpers\Html |
FLOAT_RIGHT | 'pull-right' | Bootstrap float right CSS | kartik\helpers\Html |
HIDDEN | 'hidden' | Bootstrap CSS for hidden items | kartik\helpers\Html |
IMAGE_REPLACER | 'text-hide' | Bootstrap CSS for image replacer to hide text | kartik\helpers\Html |
INVISIBLE | 'invisible' | Bootstrap CSS for invisible items | kartik\helpers\Html |
NAVBAR_FLOAT_LEFT | 'navbar-left' | Bootstrap float left CSS for navigation bar | kartik\helpers\Html |
NAVBAR_FLOAT_RIGHT | 'navbar-right' | Bootstrap float right CSS for navigation bar | kartik\helpers\Html |
SCREEN_READER | 'sr-only' | Bootstrap CSS for screen reader display | kartik\helpers\Html |
SHOW | 'show' | Bootstrap CSS for visible items | kartik\helpers\Html |
SIZE_LARGE | 'lg' | Bootstrap large size modifier | kartik\helpers\Html |
SIZE_MEDIUM | 'md' | Bootstrap medium size modifier (this is the default size) | kartik\helpers\Html |
SIZE_SMALL | 'sm' | Bootstrap small size modifier | kartik\helpers\Html |
SIZE_TINY | 'xs' | Bootstrap extra small size modifier | kartik\helpers\Html |
TYPE_DANGER | 'danger' | The danger bootstrap contextual color type | kartik\helpers\Html |
TYPE_DEFAULT | 'default' | The default bootstrap contextual color type | kartik\helpers\Html |
TYPE_INFO | 'info' | The information bootstrap contextual color type | kartik\helpers\Html |
TYPE_PRIMARY | 'primary' | The primary bootstrap contextual color type | kartik\helpers\Html |
TYPE_SUCCESS | 'success' | The success bootstrap contextual color type | kartik\helpers\Html |
TYPE_WARNING | 'warning' | The warning bootstrap contextual color type | kartik\helpers\Html |
Method Details
Generates a bootstrap abbreviation.
Example:
echo Html::abbr('HTML', 'HyperText Markup Language') . ' is the best thing since sliced bread';
echo Html::abbr('HTML', 'HyperText Markup Language', true);
public static string abbr ( $content, $title, $initialism = false, $options = [] ) | ||
$content | string | The abbreviation content |
$title | string | The abbreviation title |
$initialism | boolean | If set to true, will display a slightly smaller font-size. |
$options | array | Html options for the abbreviation |
Generates an active bootstrap checkbox button group. A checkbox button group allows multiple selection, like listBox(). As a result, the corresponding submitted value is an array. The selection of the checkbox button group is taken from the value of the model attribute.
Example:
echo Html::activeCheckboxButtonGroup($model, 'attr', [1 => 'Check 1', 2 => 'Check 2', 3 => 'Check 3']);
See also http://getbootstrap.com/javascript/#buttons-checkbox-radio.
public static string activeCheckboxButtonGroup ( $model, $attribute, $items, $options = [] ) | ||
$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:
See renderTagAttributes() for details on how attributes are being rendered. |
return | string | The generated bootstrap checkbox button group |
---|
Generates an active bootstrap radio button group. A radio button group is like a checkbox button group, except that it only allows single selection. The selection of the radio buttons is taken from the value of the model attribute.
Example:
echo Html::activeRadioButtonGroup($model, 'attr', [1 => 'Option 1', 2 => 'Option 2', 3 => 'Option 3']);
See also http://getbootstrap.com/javascript/#buttons-checkbox-radio.
public static string activeRadioButtonGroup ( $model, $attribute, $items, $options = [] ) | ||
$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:
See renderTagAttributes() for details on how attributes are being rendered. |
return | string | The generated bootstrap radio button group |
---|
Generates a bootstrap address block.
Example:
echo Html::address(
'Twitter, Inc.',
['795 Folsom Ave, Suite 600', 'San Francisco, CA 94107'],
['Res' => '(123) 456-7890', 'Off'=> '(456) 789-0123'],
['Res' => 'first.last@example.com', 'Off' => 'last.first@example.com']
);
$address = Html::address(
'Twitter, Inc.',
['795 Folsom Ave, Suite 600', 'San Francisco, CA 94107'],
['Res' => '(123) 456-7890', 'Off'=> '(456) 789-0123'],
['Res' => 'first.last@example.com', 'Off' => 'last.first@example.com'],
Html::icon('phone'),
Html::icon('envelope')
);
echo Html::well($address, Html::SIZE_TINY);
public static string address ( $name, $lines = [], $phone = [], $email = [], $options = [], $phoneLabel = '(P)', $emailLabel = '(E)' ) | ||
$name | string | The addressee name. |
$lines | array | The lines of address information. |
$phone | array | The list of phone numbers - passed as $key => $value, where:
|
array | The list of email addresses - passed as $key => $value, where:
|
|
$options | array | Html options for the address. |
$phoneLabel | string | The prefix label for each phone - defaults to '(P)'. |
$emailLabel | string | The prefix label for each email - defaults to '(E)'. |
Generates a badge.
Example:
echo Html::badge('10');
echo Html::badge('20', ['font-size' => '16px']);
public static string badge ( $content, $options = [], $tag = 'span' ) | ||
$content | string | The badge content |
$options | array | HTML attributes / options for the label container |
$tag | string | The label container tag. Defaults to 'span'. |
throws | Exception |
---|
Generates a bootstrap blockquote.
Example:
echo Html::blockquote(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.',
'Someone famous in {source}',
'International Premier League',
'IPL'
);
public static string blockquote ( $content, $citeContent = '', $citeTitle = '', $citeSource = '', $options = [], $contentOptions = [], $footerOptions = [] ) | ||
$content | string | The blockquote content |
$citeContent | string | The content of the citation (optional) - this should typically include the tag '{source}' to embed the cite source |
$citeTitle | string | The cite source title (optional) |
$citeSource | string | The cite source (optional) |
$options | array | HTML attributes for the blockquote main container |
$contentOptions | array | HTML attributes for the blockquote content container. For Bootstrap 4.x, the CSS
class
|
$footerOptions | array | HTML attributes for the blockquote footer container. Applicable only for Bootstrap 4.x releases. |
throws | Exception |
---|
Generates a bootstrap label markup.
Example:
echo Html::bsLabel('Draft');
echo Html::bsLabel('Inactive', 'danger');
echo Html::bsLabel('Active', 'success');
public static string bsLabel ( $content, $type = 'default', $options = [], $tag = 'span', $prefix = null ) | ||
$content | string | The label content |
$type | string | The bootstrap label type. Defaults to 'default'. Should be one of the bootstrap contextual colors: 'default, 'primary', 'success', 'info', 'danger', 'warning'. |
$options | array | HTML attributes / options for the label container |
$tag | string | The label container tag. Defaults to 'span'. |
$prefix | string | The CSS class prefix. Defaults to null and will be auto parsed based on BS Version. |
throws | Exception |
---|
Generates a bootstrap caret.
Example:
echo 'Down Caret ' . Html::caret();
echo 'Up Caret ' . Html::caret('up');
echo 'Disabled Caret ' . Html::caret('down', true);
See also http://getbootstrap.com/css/#helper-classes-carets.
public static string caret ( $direction = 'down', $disabled = false, $options = [], $tag = 'span' ) | ||
$direction | string | Whether to display as 'up' or 'down' direction. Defaults to |
$disabled | boolean | If the caret is to be displayed as disabled. Defaults to |
$options | array | Html options for the caret container. |
$tag | string | The html tag for rendering the caret. Defaults to |
Generates a bootstrap checkbox button group. A checkbox button group allows multiple selection, like listBox(). As a result, the corresponding submitted value is an array.
Example:
echo Html::checkboxButtonGroup('cbx', [1, 2], [1 => 'Check 1', 2 => 'Check 2', 3 => 'Check 3']);
See also http://getbootstrap.com/javascript/#buttons-checkbox-radio.
public static string checkboxButtonGroup ( $name, $selection = null, $items = [], $options = [] ) | ||
$name | string | The name attribute of each checkbox. |
$selection | string|array | The selected value(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:
See renderTagAttributes() for details on how attributes are being rendered. |
return | string | The generated checkbox button group |
---|
Generates a generic bootstrap close icon button for dismissing content like modals and alerts.
Example:
echo Html::closeButton();
echo Html::closeButton(Html::icon('remove-sign');
public static string closeButton ( $label = '×', $options = [], $tag = 'button' ) | ||
$label | string | The close icon label. Defaults to |
$options | array | HTML attributes / options for the close icon button. |
$tag | string | The HTML tag for rendering the close icon. Defaults to |
Generates a bootstrap toggle button group (checkbox or radio type)
See also http://getbootstrap.com/javascript/#buttons-checkbox-radio.
public static string getButtonGroup ( $type, $name, $selection = null, $items = [], $options = [] ) | ||
$type | string | Whether checkbox or radio. |
$name | string | The name attribute of each checkbox. |
$selection | string|array | The selected value(s). |
$items | array | The data item used to generate the checkboxes/radios. The array keys are the checkbox/radio values, while the array values are the corresponding labels. |
$options | array | Options (name => config) for the checkbox/radio list container tag. The following options are specially handled:
See renderTagAttributes() for details on how attributes are being rendered. |
return | string | The generated toggle button group |
---|
Processes and generates each list group item
protected static string getListGroupItem ( $item, $itemOptions = [], $badgeOptions = [] ) | ||
$item | array | The list item configuration. The following array key properties can be setup:
|
$itemOptions | array | HTML attributes for the list group item options (will be overridden by
|
$badgeOptions | array | HTML attributes for the list group item badge options (will be overridden by
|
throws | Exception |
---|
Processes and generates each media item
protected static string getMediaItem ( $item = [], $srcOptions = [], $imgOptions = [], $headingOptions = [], $bodyOptions = [], $itemOptions = [], $tag = 'div' ) | ||
$item | array | The media item configuration |
$srcOptions | array | Html options for the media article link. |
$imgOptions | array | Html options for the media image. |
$headingOptions | array | HTML attributes / options for the media item heading container. |
$bodyOptions | array | HTML attributes / options for the media item body container. |
$itemOptions | array | HTML attributes / options for the media item container. |
$tag | string | The media item container tag |
throws | Exception |
---|
Processes media items array to generate a recursive list.
protected static string getMediaList ( $items, $srcOptions = [], $imgOptions = [], $headingOptions = [], $bodyOptions = [], $itemOptions = [] ) | ||
$items | array | The media items |
$srcOptions | array | Html options for the media article link. |
$imgOptions | array | Html options for the media image. |
$headingOptions | array | HTML attributes / options for the media item heading container. |
$bodyOptions | array | HTML attributes / options for the media item body container. |
$itemOptions | array | HTML attributes / options for the media item container. |
throws | Exception |
---|
Generates panel content
protected static string getPanelContent ( $content, $type ) | ||
$content | array | The panel content components. |
$type | string | One of the content settings |
throws | Exception |
---|
Generates panel title for heading and footer.
protected static string getPanelTitle ( $content, $type, $widget ) | ||
$content | array | The panel content settings. |
$type | string | Whether |
$widget | kartik\base\Widget | The widget object |
throws | \Exception|\Exception |
---|
Check if HTML options has specified CSS class
protected static boolean hasCssClass ( $options, $cssClass ) | ||
$options | array | The HTML options |
$cssClass | string | The css class to test |
Generates a bootstrap icon markup.
Example:
echo Html::icon('pencil');
echo Html::icon('trash', ['style' => 'color: red; font-size: 2em']);
echo Html::icon('plus', ['class' => 'text-success']);
public static string icon ( $icon, $options = [], $prefix = 'glyphicon glyphicon-', $tag = 'span' ) | ||
$icon | string | The bootstrap icon name without prefix (e.g. 'plus', 'pencil', 'trash') |
$options | array | HTML attributes / options for the icon container |
$prefix | string | The css class prefix - defaults to 'glyphicon glyphicon-' |
$tag | string | The icon container tag (usually 'span' or 'i') - defaults to 'span' |
Generates a jumbotron - a lightweight, flexible component that can optionally extend the entire viewport to showcase key content on your site.
Example:
echo Html::jumbotron(
'<h1>Hello, world</h1><p>This is a simple jumbotron-style component for calling extra attention to featured
content or information.</p>'
);
echo Html::jumbotron([
'heading' => 'Hello, world!',
'body' => 'This is a simple jumbotron-style component for calling extra attention to featured content or information.'
]);
echo Html::jumbotron([
'heading' => 'Hello, world!',
'body' => 'This is a simple jumbotron-style component for calling extra attention to featured content or information.'
'buttons' => [
[
'label' => 'Learn More',
'icon' => 'book',
'url' => '#',
'type' => Html::TYPE_PRIMARY,
'size' => Html::LARGE
],
[
'label' => 'Contact Us',
'icon' => 'phone',
'url' => '#',
'type' => Html::TYPE_DANGER,
'size' => Html::LARGE
]
]
]);
public static string jumbotron ( $content = [], $fullWidth = false, $options = [] ) | ||
$content | string|array | The list item content. When passed as a string, it will display this directly as a raw content. When passed as an array, it requires these keys:
|
$fullWidth | boolean | Whether this is a full width jumbotron without any corners. Defaults to |
$options | array | HTML attributes / options for the jumbotron container. |
Generates a list group. Flexible and powerful component for displaying not only simple lists of elements, but complex ones with custom content.
Example:
echo Html::listGroup([
[
'content' => 'Cras justo odio',
'url' => '#',
'badge' => '14',
'active' => true
],
[
'content' => 'Dapibus ac facilisis in',
'url' => '#',
'badge' => '2'
],
[
'content' => 'Morbi leo risus',
'url' => '#',
'badge' => '1'
],
]);
echo Html::listGroup([
[
'content' => ['heading' => 'Heading 1', 'body' => 'Cras justo odio'],
'url' => '#',
'badge' => '14',
'active' => true
],
[
'content' => ['heading' => 'Heading 2', 'body' => 'Dapibus ac facilisis in'],
'url' => '#',
'badge' => '2'
],
[
'content' => ['heading' => 'Heading 2', 'body' => 'Morbi leo risus'],
'url' => '#',
'badge' => '1'
],
]);
public static string listGroup ( $items = [], $options = [], $itemOptions = [], $badgeOptions = [] ) | ||
$items | array | The list group items. The following array key properties can be setup:
|
$options | array | HTML attributes for the list group container. The following special option is recognized:
|
$itemOptions | array | HTML attributes for the list group item options (will be overridden by
|
$badgeOptions | array | HTML attributes for the list group item badge options (will be overridden by
|
throws | yii\base\InvalidConfigException |
---|
Generates a bootstrap media object. Abstract object styles for building various types of components (like blog comments, Tweets, etc) that feature a left-aligned or right-aligned image alongside textual content.
Example:
echo Html::media(
'Media heading 1',
'Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo.',
'#',
'http://placehold.it/64x64'
);
public static string media ( $heading = '', $body = '', $src = '', $img = '', $srcOptions = [], $imgOptions = [], $headingOptions = [], $bodyOptions = [], $options = [], $tag = 'div' ) | ||
$heading | string | The media heading. |
$body | string | The media content. |
$src | string|array | URL for the media article source. |
$img | string|array | URL for the media image source. |
$srcOptions | array | Html options for the media article link. |
$imgOptions | array | Html options for the media image. |
$headingOptions | array | HTML attributes / options for the media object heading container. |
$bodyOptions | array | HTML attributes / options for the media object body container. |
$options | array | HTML attributes / options for the media object container. |
$tag | string | The media container tag. Defaults to 'div'. |
throws | Exception |
---|
Generates bootstrap list of media (useful for comment threads or articles lists).
Example:
echo Html::mediaList([
[
'heading' => 'Media heading 1',
'body' => 'Cras sit amet nibh libero, in gravida nulla. ' .
'Nulla vel metus scelerisque ante sollicitudin commodo. '.
'Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.',
'src' => '#',
'img' => 'http://placehold.it/64x64',
'items' => [
[
'heading' => 'Media heading 1.1',
'body' => 'Cras sit amet nibh libero, in gravida nulla. ' .
'Nulla vel metus scelerisque ante sollicitudin commodo. ' .
'Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.',
'src' => '#',
'img' => 'http://placehold.it/64x64'
],
[
'heading' => 'Media heading 1.2',
'body' => 'Cras sit amet nibh libero, in gravida nulla. ' .
'Nulla vel metus scelerisque ante sollicitudin commodo. ' .
'Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.',
'src' => '#',
'img' => 'http://placehold.it/64x64'
],
]
],
[
'heading' => 'Media heading 2',
'body' => 'Cras sit amet nibh libero, in gravida nulla. ' .
'Nulla vel metus scelerisque ante sollicitudin commodo. ' .
'Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.',
'src' => '#',
'img' => 'http://placehold.it/64x64'
],
]);
public static string mediaList ( $items = [], $options = [] ) | ||
$items | array | The configuration of media items. Each item is an array consisting of following array keys:
|
$options | array | HTML attributes / options for the media list object container. |
throws | Exception |
---|
Generates a page header.
Example:
echo Html::pageHeader(
'Example page header',
'Subtext for header'
);
public static string pageHeader ( $title, $subTitle = '', $options = [] ) | ||
$title | string | The title to be shown |
$subTitle | string | The subtitle to be shown as subtext within the title |
$options | array | HTML attributes/ options for the page header |
Generates a panel for boxing content.
Example:
echo Html::panel([
'heading' => 'Panel Title',
'body' => 'Panel Content',
'footer' => 'Panel Footer',
], Html::TYPE_PRIMARY);
public static string panel ( $content = [], $type = 'default', $options = [], $prefix = null ) | ||
$content | array | The panel content configuration. The following properties can be setup:
|
$type | string | The panel type which can be one of the bootstrap color modifier constants. Defaults to TYPE_DEFAULT.
|
$options | array | HTML attributes / options for the panel container |
$prefix | string | The CSS prefix for panel type. Defaults to |
throws | Exception |
---|
Generates a bootstrap radio button group. A radio button group is like a checkbox button group, except that it only allows single selection.
Example:
echo Html::radioButtonGroup('rdo', [1], [1 => 'Option 1', 2 => 'Option 2', 3 => 'Option 3']);
See also http://getbootstrap.com/javascript/#buttons-checkbox-radio.
public static string radioButtonGroup ( $name, $selection = null, $items = [], $options = [] ) | ||
$name | string | The name attribute of each radio. |
$selection | string|array | The selected value(s). |
$items | array | The data item used to generate the radios. The array keys are the radio values, while the array values are the corresponding labels. |
$options | array | Options (name => config) for the radio list container tag. The following options are specially handled:
See renderTagAttributes() for details on how attributes are being rendered. |
return | string | The generated radio button group |
---|
Generates a well container.
public static string well ( $content, $size = '', $options = [] ) | ||
$content | string | The content |
$size | string | The well size. Should be one of the bootstrap size modifiers:
|
$options | array | HTML attributes / options for the well container. |
throws | Exception |
---|