public function actionCreate($node = null) { if (Yii::$app->user->isGuest) { Yii::$app->getSession()->setFlash('danger', '你需要登陆之后才能创作新主题'); return $this->redirect('/account/login?next=/topic/create'); } if (Yii::$app->user->identity->email_status == 0) { $this->goHome(); } $this->title = '创作新主题 - ' . Yii::$app->name; $this->description = ''; if (!empty($node)) { if (($model = Node::findOne(['enname' => $node])) !== null) { $node = $model; } else { $node = null; } } $model = new Topic(); if (!empty($node)) { $model->node_id = $node->id; } $topicContent = new TopicContent(); if ($model->load(Yii::$app->request->post()) && $model->create()) { $this->redirect('/topic/' . $model->id); } else { return $this->render('create', ['model' => $model, 'node' => $node, 'topicContent' => $topicContent]); } }