Esempio n. 1
0
 /**
  * Updates an existing Video 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);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         //VideoTag::deleteAll(['video_id' => $model->id]);
         $tags = Yii::$app->request->post('Video')['tags'];
         foreach ($tags as &$arr) {
             $tagvid = new VideoTag();
             $tagvid->created_by = Yii::$app->user->id;
             $tagvid->tag_id = $arr;
             $tagvid->video_id = $model->id;
             $tagvid->save();
         }
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }