public function actionAddbrand() { $user = new AdminUser(); if (!$user->checkUserIsLogin()) { $this->redirect(Variable::$home_url); return; } $req = Yii::$app->request; //创建一个请求对象 $form = new CustomerForm(); $customerModel = new Customer(); //添加 $form->setScenario('create'); $form->level = Variable::$customer_type_p; $catModel = Customer::find()->where(['level' => Variable::$customer_type_c])->all(); // $form->parentId=$id if ($form->load($req->post()) && $form->validate()) { if ($customerModel->addCus($form->name, $form->sort, $form->level, $form->parentId, $form->clogo, $form->blogo)) { Yii::$app->session->setFlash(Variable::$flash_success, '添加成功'); $this->redirect(Variable::$customerBrand_url); return; } else { Yii::$app->session->setFlash(Variable::$flash_error, '添加失败,请重试'); } } return $this->render(Variable::$addBrand_view, ['model' => $form, 'catModel' => $catModel]); }