// 删除功能
public function actionDel() {
$adminid = (int)Yii::$app->request->get('adminid');
$page = (int)Yii::$app->request->get('page');
if (empty($adminid)) {
return $this->render('manage/managers');
}
$model = new Admin;
if ($model->deleteAll('adminid = :id', [':id' => $adminid])) {
Yii::$app->session->setFlash('info', '删除成功');
$this->redirect(['manage/managers', 'page' => $page]);
}
}
As shown above, I want to delete a user in the administrator list page and stay on the current list page, but the page parameter in the URL
cannot be obtained here.
Thank you for all the answers.
If you use the grid component that comes with yii2, the deletion will be automatically assembled and passed for post, and the page information will not be passed by default, so it will not be obtained no matter what method is used, so you need to customize it yourself. Delete button option passes these parameters.
Is the deletion request you sent in the get method? If you use ajax post method on the front end, you should use Yii::$app->request->post('page'). If you think there is a problem with the parameters, you can use
var_dump(Yii::$app ->request->bodyParams);
Check whether all the parameters have been passedSolved, you need to pass the page parameter of the current page in the deleted link, not just the id.