Hi,
i’m having a problem and i don’t know why. The question is that i’m using a kartik grid (wonderfull extension) where i have a custom delete action (by row).
This is the code i’m using in index.php view to override delete action:
[ 'class' => 'kartik\grid\ActionColumn',
'dropdown' => false,
'vAlign'=>'middle',
'template' => '{update} {delete}',
'buttons' => [
'delete' => function ($url, $model, $key) {
if (Yii::$app->user->identity->id != $model->id) {
return Html::a('<span class="glyphicon glyphicon-trash"></span>',
Url::to(['users/delete', 'id' => $model->id]),
[
'title' => Yii::t('app', 'Eliminar'),
'data-pjax' => '1',
'data' => [
'method' => 'post',
'confirm' => Yii::t('app', 'Estás seguro de eliminar el usuario? El usuario dejará de estar disponible en el sistema.')],
] );
}
},
]
],
And my controller action is next:
public function actionDelete($id)[/size]
{
$user = $this->findModel($id);
$user->deleted = 1;
$user->save();
return;
//return $this->redirect(['index']);
}
If i don’t use custom delete action all works ok when i delete a row, and my grid reloads without reloading full page. But when i use the custom delete action doesn’t work. Maybe the Html::a method has a bad syntax? [size=“2”]Any ideas?[/size]
Thanks a lot in advance!