/** * Creates a new Games model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Games(); if ($model->load(Yii::$app->request->post())) { $model->city = $model->home->city; $model->stadium = $model->home->stadium; $model->score = '0:0'; if ($model->save()) { if (!empty($_FILES['UploadForm']['tmp_name']['file'])) { $model->removeImages(); $model->attachImage($_FILES['UploadForm']['tmp_name']['file']); if ($model->errors) { var_dump($model->errors); die; } } return $this->redirect(['view', 'id' => $model->id]); } else { var_dump($model->errors); exit; } } else { return $this->render('create', ['model' => $model]); } }