$this->modelClass, 'scenario' => 'default', 'partialMatchAttributes' => [], // 模糊查询 'defaultOrder' => [ 'sort' => SORT_ASC, 'id' => SORT_DESC ], 'pageSize' => $this->pageSize ]); $dataProvider = $searchModel ->search(Yii::$app->request->queryParams); return $this->render('index', [ 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, ]); } /** * 编辑/创建 * * @return mixed */ public function actionEdit() { $id = Yii::$app->request->get('id', null); $model = $this->findModel($id); $model->status= StatusEnum::ENABLED; // $model->updated_at = time(); if ($model->load(Yii::$app->request->post())) { return $model->save() ? $this->message('保存成功', $this->redirect(['index'])) : $this->message('保存失败', $this->redirect(['index']), 'error'); } return $this->render($this->action->id, [ 'model' => $model, ]); } }