/** * 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()) { if (isset($_POST['name']) && is_array($_POST['name'])) { foreach ($_POST['name'] as $lang => $val) { $model->setName($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]); } }