/** * Creates a new Category model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Category(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Category model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Category(); if ($model->load(Yii::$app->request->post())) { $model->url = $this->utf8convert($model->name); $model->save(); return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model]); } }
public function actionCreate() { $model = new Category(); //$models = Category::getListCategory(); if ($model->isNewRecord) { $model->active = 1; } if ($model->load(Yii::$app->request->post()) && $model->save()) { $this->fileAttach($model); return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Category model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Category(); if ($model->load(Yii::$app->request->post())) { $imageName = $model->category; $model->file = UploadedFile::getInstance($model, 'image'); $model->image = $imageName . '.' . $model->file->extension; $model->save(); $model->file->saveAs('uploads/' . $model->image); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }