我是 yii2 的新手。我一直在尝试使用 post 方法从 View 向操作发送一些参数,不幸的是我的操作似乎看不到/接收它们。非常感谢您的帮助。
我的专栏操作是这样的:
'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'],
]);
},
.....
数据参数中的所有内容都应通过邮寄方式发送,但我只得到 csrf token .. 预先感谢您的帮助。
最佳答案
使用下面的代码
echo Html::a('Name', ['controller/action'], [
'class'=>'classname',
'data'=>[
'method'=>'post',
'confirm'=>'Are you sure? OK to continue Retract..',
'params'=>[
'param1'=>'value',
.......,
],
]
]);
关于php - 如何从yii2 gridview发送post参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27647260/