feat: delete param

This commit is contained in:
b1ek 2024-08-21 12:08:55 +10:00
parent 58d0edb8fc
commit d87571171c
Signed by: blek
GPG Key ID: 14546221E3595D0C
2 changed files with 12 additions and 1 deletions

View File

@ -83,4 +83,14 @@ class ListController extends \yii\web\Controller
$param->save();
return $this->redirect('/list?ParameterSearch[id]='. $id);
}
public function actionDel(Request $request)
{
$id = $request->getQueryParam('id');
$param = ParameterSearch::find()->where([ 'id'=> $id ])->one();
if ($param !== null) {
$param->delete();
}
return $this->redirect('/list');
}
}

View File

@ -68,7 +68,8 @@ $this->title = 'params list';
[
'label' => 'Edit',
'value' => function (Parameter $model) {
return Html::a('Edit', '/list/edit?id=' . $model->id, [ 'class' => 'btn btn-sx btn-secondary' ]);
return Html::a('Edit', '/list/edit?id=' . $model->id, [ 'class' => 'w-100 btn btn-sx btn-secondary' ]) .
Html::a('Delete', '/list/del?id=' . $model->id, [ 'class' => 'w-100 btn btn-sx btn-danger' ]);
},
'format' => 'raw',
],