Exemplo n.º 1
0
 /**
  * Updates an existing Region model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     for ($i = 1; $i <= Lang::find()->count(); $i++) {
         $model_content[$i] = RegionLang::findOne(['id' => $id, 'lang_id' => $i]);
     }
     if (Model::loadMultiple($model_content, Yii::$app->request->post()) && Model::validateMultiple($model_content)) {
         foreach ($model_content as $key => $content) {
             $content->save(false);
         }
         return $this->redirect(['/region']);
     } else {
         return $this->render('update', ['model' => $model, 'model_content' => $model_content]);
     }
 }
Exemplo n.º 2
0
 public function getContent($lang_id = null)
 {
     $lang_id = $lang_id === null ? Lang::getCurrent()->id : $lang_id;
     return $this->hasOne(RegionLang::className(), ['id' => 'id'])->where('lang_id = :lang_id', [':lang_id' => $lang_id]);
 }