Join GitHub today
Enhancement: CButtonColumn buttonUrlController property #1499
I think originally cgridview was going to be redesigned, but later it was decided to just keep it the same? If so, I think it would be neat to add a buttonUrlController (or whatever named) property that we could set that would modify the edit, view, delete button URL's.
So for example instead of:
array( 'class'=>'CButtonColumn', 'viewButtonUrl' => 'Yii::app()->createUrl("user/view", array("id"=>$data->primaryKey))', 'updateButtonUrl' => 'Yii::app()->createUrl("user/update", array("id"=>$data->primaryKey))', 'deleteButtonUrl' => 'Yii::app()->createUrl("user/delete", array("id"=>$data->primaryKey))' ),
we can do:
array( 'class'=>'CButtonColumn', 'buttonUrlController' => 'user' ),
The purpose of this is so we can have multiple cgrdiviews in a single page without having to specify the buttonUrl's for each.
Oh I see its ActionColumn now instead of CButtonColumn. In any case here is the issue:
Say I create a grid for a User model but I want this grid on site/index page. The edit/delete/view urls are now ?r=site/update&id=1 for example. I want the actions to stay in the User controller though.
In Yii1 you would fix that by using updateButtonUrl property. I assume there is similar functionality in Yii2 but i'm not sure how to do that yet.
In any case, what i'm asking is, instead of using updateButtonUrl, can we add a global option that changes the controller name for all 3 actions in ActionColumn.
I had created a Pull request #1466 to handle ActionColumn default buttons better. Not heard from the team since.
In the interim to handle this you need to override and pass the
For modifying only the url for each button -- you could pass the