Esempio n. 1
0
 /**
  * Creates a new GoodsCategory model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new GoodsCategory();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Esempio n. 2
0
 public function actionCatadd()
 {
     $model = new GoodsCategory();
     //得到所有子孙数据 填充到下拉列表
     $cate = $model->list_cate();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->save()) {
             Yii::$app->getSession()->setFlash('info', '添加成功!');
             return $this->redirect(['catlist']);
         } else {
             Yii::$app->getSession()->setFlash('info', '添加失败!');
             return $this->redirect(['catlist']);
         }
     }
     return $this->render('catadd', ['model' => $model, 'cate' => $cate]);
 }