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