public function actionCreate() { $model = new Banner(); if ($model->load(\Yii::$app->request->post())) { if ($model->validate() && $model->save()) { return $this->redirect(['index']); } } return $this->render('form', ['model' => $model]); }
/** * Creates a new Banner model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Banner(); $model->weight = 0; $model->region = Banner::REGION_FIRST_COLUMN; 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() { $model = new Banner(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { $file = UploadedFile::getInstance($model, 'name'); if ($fileModel = FileModel::saveAs($file, '@common/upload')) { } if ($model->load(Yii::$app->request->post()) && $model->validate()) { if ($model->saveUploadedFile() !== false) { $model->save(); return $this->redirect('banner/create', ['model' => $model]); } } else { return $this->render('create', ['model' => $model]); } } }