Yii 2 Grid, change view button URL

Hi,

How do I change the Yii 2 Grid view button URL in Yii action column.

I do not want to use the default.

James.

What do you want to change : The URL or the icon of the button ?

The URL.

You can change the ID of the controller : http://www.yiiframework.com/doc-2.0/yii-grid-actioncolumn.html#$controller-detail

And the action is the name of the button (key)

Try this




 <?= GridView::widget([

     'dataProvider' => $dataProvider,

     'filterModel' => $searchModel,

     'columns' => [

         ['class' => 'yii\grid\SerialColumn'],

.........

         [

	'class' => 'yii\grid\ActionColumn',

	'template' => '{view} {update} {delete} {link}',

	'buttons' => [

		'update' => function ($url,$model) {

			return Html::a(

				'<span class="glyphicon glyphicon-user"></span>', 

				$url);

		},

		'link' => function ($url,$model,$key) {

				return Html::a('Action', $url);

		},

	],

],

     ],

 ]); ?>




This worked.

Thanks guys.

The new approach in Yii 2 gives more flexibility but it is not as basic / quick as the old Yii 1 method of doing it.

But I do like the new approach better.