New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: CButtonColumn buttonUrlController property #1499

Closed
nsanden opened this Issue Dec 13, 2013 · 4 comments

Comments

Projects
None yet
4 participants
@nsanden
Contributor

nsanden commented Dec 13, 2013

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.

@qiangxue

This comment has been minimized.

Show comment
Hide comment
@qiangxue

qiangxue Dec 13, 2013

Member

In Yii 2, there is ActionColumn. Is it what you want?

Member

qiangxue commented Dec 13, 2013

In Yii 2, there is ActionColumn. Is it what you want?

@nsanden

This comment has been minimized.

Show comment
Hide comment
@nsanden

nsanden Dec 13, 2013

Contributor

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.

Contributor

nsanden commented Dec 13, 2013

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.

@kartik-v

This comment has been minimized.

Show comment
Hide comment
@kartik-v

kartik-v Dec 14, 2013

Contributor

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 buttons property to ActionColumn in your gridview.

For modifying only the url for each button -- you could pass the urlCreator property as a Closure.

Contributor

kartik-v commented Dec 14, 2013

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 buttons property to ActionColumn in your gridview.

For modifying only the url for each button -- you could pass the urlCreator property as a Closure.

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Dec 14, 2013

Contributor

One more thing, i think in Yii2 action columns buttons (a-tags) should consider csrf protection, and when it is on, then global event listener should be applied on table container to catch events and submit POST requests with csrf token when needed.

Contributor

Ragazzo commented Dec 14, 2013

One more thing, i think in Yii2 action columns buttons (a-tags) should consider csrf protection, and when it is on, then global event listener should be applied on table container to catch events and submit POST requests with csrf token when needed.

@qiangxue qiangxue closed this in 5fc275e Dec 23, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment