/** * Creates a new Pages model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Pages(); $statusArray = Pages::getPagesStatusArray(); $categoryArray = Category::getCategoryArray(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model, 'statusArray' => $statusArray, 'categoryArray' => $categoryArray]); } }
/** * Creates a new Pages model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Pages(); $media = Media::find()->orderBy('id DESC')->all(); $block = Block::find()->where(['type' => ''])->all(); $arr[0] = 'Нет'; foreach ($block as $b) { $arr[$b->id] = $b->name; } if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model, 'media' => $media, 'block' => $arr]); } }