Modify Gridview Action Column Url

hi, good day everyone

In gridview action column how to modify the url of the link?

for example the default one when pressing the update button is:

http:\\yourwebsite.com\post\update\1

i need to pass additional parameters based on the current row model data, so when pressing the update button the url will be for example:

http:\\yourwebsite.com\post\update\1?type=b&author=alex

how to modify the url so that i can pass those additional parameters?

thank you very much for your time and answers

regards,

Lightning

1 Like

http://www.yiiframework.com/doc-2.0/yii-grid-actioncolumn.html#$urlCreator-detail

Kindly please provide example as how to use it? Iā€™m not that well versed in PHP

thank you very mch

regards,

Lightning

Something along those lines:




            [

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

                'urlCreator' => function( $action, $model, $key, $index ){

                    if ($action == "view") {

                        return Url::to(['view', 'id' => $key]);

                    }

                }

            ],



3 Likes

your solution works!

thank you again

regards,

Lightning