diff --git a/framework/grid/DataColumn.php b/framework/grid/DataColumn.php index c32af018ae..dab0f26c1a 100644 --- a/framework/grid/DataColumn.php +++ b/framework/grid/DataColumn.php @@ -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; } }