Added encodeLabel param to \yii\grid\DataColumn

Use case:

```
    echo GridView::widget([
        ...
        'columns' => [
            ...
            [
                'attribute' => 'created_at',
                'label' => '<span data-toggle="tooltip" class="glyphicon glyphicon-time" title="'.Yii::t('app', 'Created At').'"></span>',
                'encodeLabel' => false,
                ...
            ],
```
This commit is contained in:
Serge Postrash
2014-10-06 07:13:29 +04:00
committed by Qiang Xue
parent cfe874607f
commit c6cb205653

View File

@ -49,6 +49,10 @@ class DataColumn extends Column
* Otherwise [[\yii\helpers\Inflector::camel2words()]] will be used to get a label.
*/
public $label;
/**
* @var boolean whether the label should be HTML-encoded.
*/
public $encodeLabel = true;
/**
* @var string|\Closure an anonymous function that returns the value to be displayed for every data model.
* The signature of this function is `function ($model, $key, $index, $column)`.
@ -128,9 +132,9 @@ class DataColumn extends Column
if ($this->attribute !== null && $this->enableSorting &&
($sort = $provider->getSort()) !== false && $sort->hasAttribute($this->attribute)) {
return $sort->link($this->attribute, array_merge($this->sortLinkOptions, ['label' => Html::encode($label)]));
return $sort->link($this->attribute, array_merge($this->sortLinkOptions, ['label' => ($this->encodeLabel ? Html::encode($label) : $label)]));
} else {
return Html::encode($label);
return $this->encodeLabel ? Html::encode($label) : $label;
}
}