Label

Highlighting the important

This is the helper to create the Twitter Bootstrap badge markers.

Note Using this widget will not help you reduce the count of symbols you have to type to get a badge in your view! Quite the contrary, you'll need to write more. You have to make your own shorthands, if you want. This widget solves the problem of properly building the required HTML scaffolding and nothing else.

Basic example of usage is this:

Success
$this->widget(
    'booster.widgets.TbLabel',
    array(
        'context' => 'success',
        // 'default', 'primary', 'success', 'info', 'warning', 'danger'
        'label' => 'Success',
    )
);

Here's all configuration properties which you can set for TbLabel widget.

Property Description
string context = "default" Label type, that is, it's color. See the Twitter Bootstrap label documentation to see what values are supported by Bootstrap styles.
string label = "" What will be printed on the label
boolean encodeLabel = true Whether to HTML-encode the contents of the label. If set to false, you can include other HTML inside the label.
array htmlOptions = array() HTML attributes of the label element. Note that this element will be span.

Labels showcase

defaultprimarysuccessinfowarningdanger
foreach(
    array('default', 'primary', 'success', 'info', 'warning', 'danger')
    as $context
) {
    $label = $context;
    $this->widget('booster.widgets.TbLabel', compact('context', 'label'));
}

TbLabel defines a set of class constants to help users of widget define allowed label types uniformly. Each TYPE_* constant corresponds to some CSS class which will be appended to the label HTML element. This class mainly just sets the color of the label background, nothing else. For details see the documentation for Twitter Bootstrap Label widget.

Name Description
TYPE_DEFAULT Corresponds to label-default CSS class.
TYPE_PRIMARY Corresponds to label-primary CSS class.
TYPE_SUCCESS Corresponds to label-success CSS class.
TYPE_INFO Corresponds to label-info CSS class.
TYPE_WARNING Corresponds to label-warning CSS class.
TYPE_DANGER Corresponds to label-danger CSS class.