DataColumn bug in GridView


(Decemvre) #1

This is an issue in Yii2, latest version.




								        'columns' => [

								            [

								                'attribute' => 'id',

								                'label' => 'My Label',

								                'format' => 'html',

								                'value' => function($model) {

								                    return ($model->status !== SomeClass::CONST_STATUS)?$model->id:Html::a('External Link','http://my_link_goes_here', ['class' => 'btn btn-sm btn-info', 'target' => '_blank']);

								                },

								            ],



With this code, due to the format => html, any other attribute of the a element, even id, does not show up. Only class shows up and can be modified; and ofcourse href.


(Saurabhdhariwal737) #2

You have to change ‘format’ => ‘html’ to ‘format’ => ‘raw’.

For more details about format you can refer following link.

Let me know if you face any query/concern regarding this.

Thanks!