/** * Updates an existing Block model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $firstModel = $this->findModel($id); foreach (Yii::$app->params['availableLocales'] as $key => $value) { $currentModel = Block::getLocaleInstance($key); $dataModel = $currentModel::find()->andWhere(['locale_group_id' => $firstModel->locale_group_id, 'locale' => $key])->one(); if (!empty($dataModel->domain)) { $dataModel->domain = explode(',', $dataModel->domain); } $models[$key] = $dataModel; if (!$models[$key]) { //\yii\helpers\VarDumper::dump($firstModel->attributes,11,1); die(); $currentModel->locale_group_id = $firstModel->locale_group_id; $currentModel->locale = $key; $currentModel->title = 'title ' . $key . ' ' . time(); $currentModel->slug = ''; $models[$key] = $currentModel; } } $model = new MultiModel(['models' => $models]); if ($model->load(Yii::$app->request->post()) && Block::multiSave($model)) { return $this->redirect(['index']); } else { return $this->render('update', ['model' => $model, 'domains' => array_combine(explode(',', Yii::getAlias('@frontendUrls')), explode(',', Yii::getAlias('@frontendUrls')))]); } }