how to place a picture above attribute name in GridView

Hi guys,

what I wanna achieve is easy to explain. I want to set a piture in GridView above name of attribute.I have read official documentation here, but i didn’t find a way to do it.

Is it possible, and if, how? I try like this,but get error of course





    [

	//show this on screen,above label downstairs        

	Html::img('@web/pictures/tklustig.jpg', ['alt' => 'pic not found', 'class' => 'img-width, 'style' => 'width:100px;height:25px']),

  	'attribute' => 'umkreis',

        'label' => 'Umkreis',

        'value' => function($model) {

            if ($model->umkreis) {

                return $model->umkreis;

            } else {

                return NULL;

            }

        },

        'filterType' => GridView::FILTER_SELECT2,

        'filter' => yii\helpers\ArrayHelper::map(\frontend\modules\bewerber\models\Bewerber::find()->orderBy(['id' => SORT_DESC])->asArray()->all(), 'umkreis', 'umkreis'),

        'filterWidgetOptions' => [

            'pluginOptions' => ['allowClear' => true],

        ],

        'filterInputOptions' => ['placeholder' => 'Radius in Kilometer', 'id' => 'grid-bewerber-search-umkreis'],

        'format' => 'raw',

    ],



Error is like this:




yii\base\UnknownPropertyException: Setting unknown property: kartik\grid\DataColumn::0 in E:\xampp\htdocs\yii2_perswitch\vendor\yiisoft\yii2\base\Object.php:161Stack trace:#0 E:\xampp\htdocs\yii2_perswitch\vendor\yiisoft\yii2\BaseYii.php(529): yii\base\Object->__set('0', '



This


Html::img('@web/pictures/tklustig.jpg', ['alt' => 'pic not found', 'class' => 'img-width, 'style' => 'width:100px;height:25px']),

cause a problem, obviously

I know.this is reason for error,'cause kartik doesn’t accept placing pictures like this. My question is, how to place a picture above label of attribute instead?


[

    ...

    'value' => function($model) {

        $img = Html::img('@web/pictures/tklustig.jpg', ['alt' => 'pic not found', 'class' => 'img-width', 'style' => 'width:100px;height:25px']);

        return $img . ($model->umkreis ?: 'umkreis nicht angegeben');

    },

    ...

],

U ardently don’t understand,what I want. I want a picture above label of attribute. Coding as U suggest wil constitute picture as attribute. This is already implemented. Look at my attachement,please, in order to understand,what I want. Hope this might succeed,solving my problem. Here is structure of index.php




$gridColumn=[

[ ],

[ ],

.

.

.


];

Pjax::begin();

try {

?>

 <?=

    GridView::widget([

        'dataProvider' => $dataProvider,

        'filterModel' => $searchModel,

        'filterSelector' => '.choiceRadio',

        'columns' => $gridColumn,

.

.



P.S.: I use GridView of kartik,which is documentated here. Unfortunately, there is no hint solving my problem in this documentation


[

    'attribute' => 'blabla',

    'label' => '<img src="/img/main-logo.png" class="logo-img" alt="">blabla',

    'encodeLabel' => false,

],

Great! Thx a lot for this. U helped me one more time again! That means reputation points for U,of course

This thread can be finished as solved.

Here is complete code:





    [

        'attribute' => 'umkreis',

        'label' => Html::img('@web/pictures/umkreis.jpg', ['alt' => 'pic not found', 'class' => '', 'style' => 'width:100px;height:35px']).'Umkreis',

        'encodeLabel' => false,

        'value' => function($model) {

            if ($model->umkreis) {

                return $model->umkreis;

            } else {

                return NULL;

            }

        },

        'filterType' => GridView::FILTER_SELECT2,

        'filter' => yii\helpers\ArrayHelper::map(\frontend\modules\bewerber\models\Bewerber::find()->orderBy(['id' => SORT_DESC])->asArray()->all(), 'umkreis', 'umkreis'),

        'filterWidgetOptions' => [

            'pluginOptions' => ['allowClear' => true],

        ],

        'filterInputOptions' => ['placeholder' => 'Radius in Kilometer', 'id' => 'grid-bewerber-search-umkreis'],

        'format' => 'raw',

    ],