php - The paging set by the LinkPager paging component of the yii2 framework. The controller cannot get the current page number in the URL.
为情所困
为情所困 2017-07-04 13:45:56
0
3
881
// 删除功能
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.

为情所困
为情所困

reply all(3)
刘奇

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 passed

扔个三星炸死你

Solved, you need to pass the page parameter of the current page in the deleted link, not just the id.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!