/** * Creates a new Block model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Block(); if ($model->load(Yii::$app->request->post()) && $model->save()) { if (isset($_POST['title']) && is_array($_POST['title'])) { foreach ($_POST['title'] as $lang => $val) { $model->setTitle($lang, $val); } } if (isset($_POST['content']) && is_array($_POST['content'])) { foreach ($_POST['content'] as $lang => $val) { $model->setContent($lang, $val); } } $model->updateURLCode(); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }