Exemplo n.º 1
0
 /**
  * Страница добавления автора.
  *
  * @return string|\yii\web\Response
  */
 public function actionCreate()
 {
     $modelAuthor = new Author();
     if ($modelAuthor->load(Yii::$app->request->post()) && $modelAuthor->save()) {
         return $this->redirect(['back-author/view', 'id' => $modelAuthor->id]);
     }
     return $this->render('/back/author/create', ['modelAuthor' => $modelAuthor]);
 }
Exemplo n.º 2
0
 /**
  * Creates a new Author model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Author();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Exemplo n.º 3
0
 /**
  * Создание автораа
  * @return string
  */
 public function actionCreate()
 {
     $model = new Author();
     if ($model->load(Yii::$app->request->post())) {
         $model->name = Yii::$app->request->post('Author')['name'];
         $model->status = Yii::$app->request->post('Author')['status'];
         $model->description = Yii::$app->request->post('Author')['description'];
         $model->country_id = Yii::$app->request->post('Author')['country_id'];
         $model->save(false);
         $authors = Author::find();
         $dataProvider = new ActiveDataProvider(['query' => $authors]);
         return $this->redirect(Url::toRoute('author/index'));
     } else {
         return $this->render('_form', ['model' => $model]);
     }
 }