/**
  * Creates a new Block model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = Yii::createObject(Block::className());
     if ($pageId = Yii::$app->request->get('page_id')) {
         $model->visibility = Block::VISIBILITY_PROTECTED;
     }
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         Yii::$app->session->set('new-block', $model);
         return $this->redirect(['config', 'page_id' => $pageId]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Beispiel #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getBlock()
 {
     return $this->hasOne(Block::className(), ['id' => 'block_id']);
 }