/** * Creates a new Product model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Product(); 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['description']) && is_array($_POST['description'])) { foreach ($_POST['description'] as $lang => $val) { $model->setDescription($lang, $val); } } if (isset($_POST['information']) && is_array($_POST['information'])) { foreach ($_POST['information'] as $lang => $val) { $model->setInformation($lang, $val); } } $model->updateURLCode(); return $this->redirect(['update', 'id' => $model->id, 'panel' => 'images']); } else { return $this->render('create', ['model' => $model]); } }