/** * Updates an existing Team 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); $events = Event::findAll(['active' => true]); if (!$model->event->active) { Yii::$app->session->addFlash('error', 'Teams can not be updated once an event is closed'); Yii::$app->user->setReturnUrl(Yii::$app->request->referrer); return $this->goBack(); } if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model, 'events' => $events]); } }