/** * Creates a new Vocabulary model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Vocabulary(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->date]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Vocabulary model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Vocabulary(); if (Yii::$app->request->post()) { $postData = Yii::$app->request->post(); $postData['Vocabulary']['russian'] = $model->translate($postData['Vocabulary']['german']); if ($model->load($postData) && $model->save()) { $trainings = new Trainings(); $trainings->wordId = $model->wordId; $trainings->userId = 1; // hardcoded for one user $trainings->translateWord = 1; $trainings->wordTranslate = 1; $trainings->typeWord = 1; $trainings->flashCards = 1; $trainings->insert(); return $this->redirect(['view', 'id' => $model->wordId]); } else { return $this->render('create', ['model' => $model]); } } else { return $this->render('create', ['model' => $model]); } }