/**
  * Creates a new Attribute model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     if (!$this->is_access('attribute/create')) {
         Yii::$app->session->setFlash('error', $this->errorInfo);
         return $this->redirect($this->redirectUrl);
     }
     $model = new Attribute();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('success', '添加成功');
         return $this->redirect(['index']);
     } else {
         $GoodsType = new GoodsType();
         $dropList = $GoodsType->dropList(false);
         Yii::$app->view->params['meta_title'] = '添加属性';
         return $this->render('create', ['model' => $model, 'dropList' => $dropList]);
     }
 }
 public function actionAttradd($type_id)
 {
     //添加成功后 商品属性列表页内容属于传过来的类型id
     if (Yii::$app->request->post('Attribute')) {
         $attr = Yii::$app->request->post('Attribute');
         $type_id = $attr['type_id'];
         //商品类型id
     }
     $type = GoodsType::find()->all();
     //商品类型数据填充
     $model = new Attribute();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->save()) {
             Yii::$app->getSession()->setFlash('info', '添加成功!');
             return $this->redirect(['attrlist', 'type_id' => $type_id]);
         } else {
             Yii::$app->getSession()->setFlash('info', '添加失败!');
             return $this->redirect(['attrlist', 'type_id' => $type_id]);
         }
     }
     return $this->render('attradd', ['type_id' => $type_id, 'model' => $model, 'type' => $type]);
 }