/** * Creates a new Product model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Product(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
public function actionCreate() { $params = $this->getParams(); $accountId = $this->getAccountId(); $params['accountId'] = $accountId; $productInfo = isset($params['intro']) ? $params['intro'] : ''; unset($params['intro']); //check the property of the category Product::checkParam($params, $accountId); $product = new Product(); $product->load($params, ''); if ($product->save()) { //add description $info = $product->addIntro($product->_id, $productInfo); $product->intro = $info; $product->_id .= ''; return $product; } else { throw new ServerErrorHttpException('Fail to create member'); } }