Yii2 - Pass variable from view to Gridview custom action columns

前端 未结 1 612
再見小時候
再見小時候 2021-02-07 04:18

I want to save the last place that a user visited before he click onto \"Edit\" button in the gridview widget of a page. I created a variable named $lastAddress but I really don

相关标签:
1条回答
  • 2021-02-07 05:23

    Use use to pass in variables from the parent scope to a closure:

    'update' => function ($url, $model) use ($lastAddress) {
        $url .= '&lastAddress=' . $lastAddress; //This is where I want to append the $lastAddress variable.
        return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url);
    },
    
    0 讨论(0)
提交回复
热议问题