Mam*_*mba 4 php parameters post gridview yii2
我是yii2的新手.我一直试图使用post方法从视图中向一个动作发送一些参数,不幸的是我的动作似乎没有看到/接收它们.帮助将非常感激.
我的列操作是这样的:
'buttons'=> [
'password'=> function ($url, $model, $key){
$url =$url = Url::toRoute(['users/reset-password', 'username' => $model->username]);
return Html::a('<span class="glyphicon glyphicon-asterisk"></span>',$url,[
'title'=>'Clave',
'data-confirm' => Yii::t('yii', 'Are you sure you want to change this password?'),
'data-method' => 'post',
'data' => ['username'=>$model->username, 'test-name'=>'this is just for testing'],
]);
},
.....
Run Code Online (Sandbox Code Playgroud)
data参数中的所有内容都应该通过post发送,但我只获取csrf令牌..请提前感谢您的帮助.
使用下面的代码
echo Html::a('Name', ['controller/action'], [
'class'=>'classname',
'data'=>[
'method'=>'post',
'confirm'=>'Are you sure? OK to continue Retract..',
'params'=>[
'param1'=>'value',
.......,
],
]
]);
Run Code Online (Sandbox Code Playgroud)