コード例 #1
0
 /**
  * Displays page with form to add new message and shows all messages
  *
  * @return mixed
  */
 public function actionView()
 {
     /** Start Form */
     $formSubTitle = 'Add new comment';
     $commentForm = new commentForm();
     if ($commentForm->load(Yii::$app->request->post()) && $commentForm->addComment()) {
         Yii::$app->session->setFlash('messageAdded');
         $this->redirect(Yii::$app->getUrlManager()->createUrl('comment/view'));
     }
     /** Start Comments list */
     $commentsOutputSubTitle = 'All comments';
     $comment = new Comment();
     $allComments = $comment->getAllComments();
     return $this->render('view', ['formSubTitle' => $formSubTitle, 'commentsOutputSubTitle' => $commentsOutputSubTitle, 'commentForm' => $commentForm, 'allComments' => $allComments]);
 }