Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to send post parameters from yii2 gridview

am new to yii2. I have been trying to send some parameters to an action from a view using the post method, unfortunately my action seems not to see/receive them. Help would be most appreciated.

my column action is something like this:

'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'],
                        ]);
                },
.....

everything in the data parameter should be send by post, but I only get the csrf token .. thank you in advance for help.

like image 841
Mamba Avatar asked Dec 20 '22 08:12

Mamba


1 Answers

use below code

echo Html::a('Name', ['controller/action'], [
    'class'=>'classname',
    'data'=>[
        'method'=>'post',
        'confirm'=>'Are you sure? OK to continue Retract..',
        'params'=>[
            'param1'=>'value',
            .......,
        ],
    ]
]);
like image 139
shreenu konapala Avatar answered Dec 24 '22 01:12

shreenu konapala