Button in gridview for click event


(KillerSH) #1

‘class’ => ‘yii\grid\ActionColumn’,
‘template’ => ‘{myButton}’,
‘buttons’ => [
‘myButton’ => function($url, $model, $key) { // render custom button

                    $info = file_get_contents('globalHelper/global.txt');

                    $command1 = Yii::$app->db->createCommand("CALL updatare_auxiliara(".$info. ",'".$model->nume."')");
                    $command1->execute();

                    return Html::a('Schimba', ['view', 'id' => $info], ['class' => 'btn btn-primary']);
                },

];

This is a button created for each entry in gridview. The problem is that the function for the button is called every time an entry appears in gridview. I want to call that function only when the button is clicked.
Please help.