Just like label, but more squishy
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:
$this->widget( 'booster.widgets.TbBadge', array( 'context' => 'success', // 'default', 'success', 'info', 'warning', 'danger' 'label' => '2', ) );
Here's all configuration properties which you can set for TbBadge widget.
Property | Description |
---|---|
string context = "default" |
in combination with the alert types this property determine the badge color, so value may be one of ['default', 'success', 'info', 'warning', 'danger']. |
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 this badge. |
array htmlOptions = array() |
HTML attributes of the badge element. Note that this element will be span . |
foreach( array('default', 'success', 'info', 'warning', 'danger') as $label => $context ) { $this->widget('booster.widgets.TbBadge', compact('context', 'label')); }
TbBadge
defines a set of class constants to help users of widget define allowed badge types uniformly.
Each TYPE_*
constant corresponds to some CSS class which will be appended to the badge HTML element.
This class mainly just sets the color of the badge background, nothing else. For details see the documentation
for Twitter Bootstrap Badge widget.
Name | Description |
---|---|
TYPE_DEFAULT | Corresponds to badge CSS class. |
TYPE_SUCCESS | Corresponds to badge badge-success CSS class. |
TYPE_INFO | Corresponds to badge badge-info CSS class. |
TYPE_WARNING | Corresponds to badge badge-warning CSS class. |
TYPE_DANGER | Corresponds to badge badge-danger CSS class. |