/** * Signs user up. * * @return Book|null the saved model or null if saving fails */ public function AddForm() { if ($this->validate()) { $model = new AddForm(); $model->bookname = $this->bookname; $model->authorname = $this->authorname; $model->about = $this->about; $model->page = $this->page; // $book->generateAuthKey(); if ($model->save()) { return $model; } } return null; }
public function actionAdd() { // if (!\Yii::$app->user->isGuest) { // return $this->goHome(); // }validate $model = new AddForm(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { return $this->render('add', ['model' => $model]); } else { return $this->render('add', ['model' => $model]); } }