$this->modelClass::find() ->where(['app_id' => AppEnum::BACKEND]) ->orderBy('sort asc, created_at asc'), 'pagination' => false ]); return $this->render('index', [ 'dataProvider' => $dataProvider ]); } /** * 编辑/创建 * * @return mixed|string|\yii\web\Response * @throws \yii\base\ExitException */ public function actionAjaxEdit() { $request = Yii::$app->request; $id = $request->get('id', ''); $model = $this->findModel($id); $model->pid = $request->get('pid', null) ?? $model->pid; // 父id $model->app_id = AppEnum::BACKEND; // ajax 校验 $this->activeFormValidate($model); if ($model->load($request->post())) { return $model->save() ? $this->redirect(['index']) : $this->message($this->getError($model), $this->redirect(['index']), 'error'); } return $this->renderAjax('ajax-edit', [ 'model' => $model, 'cateDropDownList' => Yii::$app->services->configCate->getDropDownForEdit(AppEnum::BACKEND, $id), ]); } }