How to create a LinkColumn in Yii 2.0?

Hi guys,

could somebody please tell me how to create a LinkColumn within the new Yii 2.0 Framework?

In the old version, i used CHtml::link to create a link in a column.

In Yii 2.0 i only find the yii\web\Link class but it didnt work …

Looking froward to get help from you.

Thanks a lot and all the best,

Daniel

If your model contains a field/attribute "internet" with an url you can add a gridview column as link this way:




            [

                'attribute' => 'internet',

                'format' => ['url']

            ],



or simplified:


'internet:url'



This will support the default gridview filter and sort functions.

If you use "raw" the column will have no filter/sort:




            [

                'format'=> 'raw',

                'value'=> function ($data) {

                    return Html::a(Html::encode($data->internet), $data->internet);

                },

            ],

You can also use this… :rolleyes:


[

   'format' => 'html',

   'attribute' => 'internet',

   'value' => function ($date) {

		return Html::a(Html::encode($data->internet), $data->internet);

    },

]