activeDataProvider输出中的函数返回yii2中的HTML [ “标签”=>“星星”, “值”=>函数($model){ $stars=$model->score; $result=“”; 对于($i=1;$i

activeDataProvider输出中的函数返回yii2中的HTML [ “标签”=>“星星”, “值”=>函数($model){ $stars=$model->score; $result=“”; 对于($i=1;$i,yii2,cactivedataprovider,Yii2,Cactivedataprovider,在GridView列中设置format为html,如下所示 <span class='star'>☆</span> <span class='star'>☆</span> <span class='star'>☆</span> [ “标签”=>“星星”, “值”=>函数($model){ $stars=$model->score; $result=“”; 对于($i=1;$i'html' ], 在GridView列选项中

GridView列中设置
format
html,如下所示

<span class='star'>☆</span> <span class='star'>☆</span> <span class='star'>☆</span>
[
“标签”=>“星星”,
“值”=>函数($model){
$stars=$model->score;
$result=“”;
对于($i=1;$i'html'
],

GridView列选项中,将
格式设置为html,如下所示

<span class='star'>☆</span> <span class='star'>☆</span> <span class='star'>☆</span>
[
“标签”=>“星星”,
“值”=>函数($model){
$stars=$model->score;
$result=“”;
对于($i=1;$i'html'
],
请参阅

[
“标签”=>“星星”,
'format'=>'html',//使用此行
“值”=>函数($model){
$stars=$model->score;
$result=“”;
对于($i=1;$i
[
“标签”=>“星星”,
'format'=>'html',//使用此行
“值”=>函数($model){
$stars=$model->score;
$result=“”;
对于($i=1;$i)
[
  'label' => 'stars',
  'value' => function($model){
      $stars = $model->score;
      $result = "";
      for($i=1; $i<=$stars;$i++){ 
          $result .= "<span class='star'>☆</span>";
      }
      return $result;
  },
  'format' => 'html'
],
         [
            'label' => 'stars',
            'format'=>'html', // Use this Line
            'value' => function($model){

                $stars = $model->score;
                $result = "";
                for($i=1; $i<=$stars;$i++){
                    $result .= '<i class="fa fa-star-half-o" aria-hidden="true"></i>';
                }
                return $result;
            },
        ],