/**
  * Action method for creating a new forum topic.
  * @return string|Response action method execution result.
  */
 public function actionCreate()
 {
     $topic = new Topic();
     if ($topic->load(Yii::$app->request->post()) && $topic->save()) {
         return $this->redirect($topic->url);
     }
     return $this->render('create', ['topic' => $topic, 'categories' => Category::find()->all(), 'sections' => empty($topic->category_id) ? [] : Section::findAll(['category_id' => $topic->category_id])]);
 }
Beispiel #2
0
 /**
  * Creates a new Topic model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Topic();
     $model->loadDefaultValues();
     $model->setScenario('update');
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'tags' => Tag::find()->all()]);
     }
 }