How to put an image in the gridview in yii2? I have the following code but this image is not displaying because it is not giving any image URL. Where is the image URL placed?
& lt ;? Php Echo Gridview :: Widgets (['Detector' => $ Detector, 'FilterModel' = & gt; $ Search Model, 'Column' = & gt; [['Class' = & gt;' yii \ grid \ SerialColumn '', 'C_id', 'name: ntext', 'description: ntext', array ('format' = & gt; 'image', 'attribute' = & gt; 'logo',), ['class' =' & Gt; 'yii \ grid \ ActionColumn'],],]); ? & Gt;
Try,
array ('format '='; 'Image', 'value' = & gt; function ($ data) {return $ data-> imageurl;},),
and in your model ,
public function getImageurl () {return \ Yii :: $ app- & gt; Request-> BaseUrl / / Lt; Path to Image & gt; /'.$ this-> Logo; }
I do not know whether this is the right way or not. But it works for me.
Comments
Post a Comment