Example:
~~~
echo Html::bsLabel('Draft');
echo Html::bsLabel('Inactive', 'danger');
echo Html::bsLabel('Active', 'success');
~~~
public static bsLabel ( string $content, string $type = 'default', array $options = [], string $prefix = 'label label-', string $tag = 'span' ) : string | ||
$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 |
$prefix | string | the CSS class prefix. Defaults to 'label label-'. |
$tag | string | the label container tag. Defaults to 'span'. |
Результат | string |
<?php use yii\grid\GridView; use kartik\helpers\Html; echo GridView::widget(['layout' => '{items}', 'dataProvider' => $volDP, 'tableOptions' => ['class' => 'table table-striped table-bordered', 'style' => 'margin-bottom: 0px'], 'columns' => [['attribute' => 'rw', 'format' => 'raw', 'value' => function ($m) { if ($m['rw'] == 'rw') { return Html::bsLabel('RW', Html::TYPE_SUCCESS); } return Html::bsLabel('RO'); }], 'local', 'remote']]);
</div> </div> </div> </div> <div class="panel-footer"><?php echo Html::button('Add Controller', ['class' => 'btn btn-success addController']); ?> </div> </div> <div class="row"> <div class="col-md-6 text-center"> <div class="panel panel-default"> <div class="panel-body"> <?php echo '<h5>Firstly, you have to put your template folder into @app/template. ' . Html::bsLabel('Required', Html::TYPE_DANGER) . '</h5>'; ?> </div> </div> </div> <div class="col-md-6 text-center"> <div class="panel panel-default"> <div class="panel-body"> <?php echo Html::label('Which file will use for layout?:'); ?> <?php echo Html::dropDownList('file', null, $fileList, ['class' => 'form-control']); ?> </div> <div class="panel-footer"><?php