Image in gridview in yii2

前端 未结 9 1803
梦毁少年i
梦毁少年i 2020-12-16 04:34

How to put an image in GridView in yii2?I have the following code. But its not displaying the image as it is not giving any image url. Where to put the image url?

         


        
9条回答
  •  天涯浪人
    2020-12-16 05:09

    Try like,

     array(
    'format' => 'image',
    'value'=>function($data) { return $data->imageurl; },
    
       ),
    

    And in your model,

    public function getImageurl()
    {
    return \Yii::$app->request->BaseUrl.'//'.$this->logo;
    }
    

    Don't know this is the right way or not.But this works for me.

提交回复
热议问题