سلام, آقای شهرکی من طبق آموزش شما در مجموعه آموزشی کامنت رو ساختم, درست کار میکنه فقط نام نویسنده کامنت ذکر نمیشود. لطفآ اگر میشه بگین ایراد کجاست
public function actionCreate() { $model=new Comment;
// Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model);
if(isset($_POST['Comment'])) { $model->attributes=$_POST['Comment']; if($model->save()) $this->redirect(array('view','id'=>$model->id)); }
$this->render('create',array( 'model'=>$model, )); }
_comments
<?php foreach ($comments as $comment):?> <div class="comment"> <div class="author"> <?php echo CHtml::encode($comment->author->username); ?>: </div> <div class="time"> on <?php echo date('F J, Y\a\t h:i a', strtotime($comment->create_time)); ?> </div> <div class="comment"> <?php echo nl2br(CHtml::encode($comment->content)); ?> </div>
<hr/> </div> <!-- comment --><?php endforeach; ?>
view.php
<div id="comments"> <?php if ($model->commentCount >= 1): ?> <h3> <?php echo $model->commentCount > 1 ? $model->commentCount . 'Comments' : 'One Comment' ; ?> </h3> <?php $this->renderPartial('_comments', array('comments' => $model->comments)) ; ?> <?php endif ; ?> <h3> Leave a Comment </h3>
<?php if (Yii::app()->user->hasFlash('commentSubmitted')): ?> <div class="flash-success"> <?php echo Yii::app()->user->getFlash('commentSubmitted'); ?> </div> <?php else: ?> <?php $this->renderPartial('/comment/_form', array('model'=> $comment)); ?> <?php endif ; ?></div>
همونطور که گفتم کامنت ثبت میشه ولی پیغام فلش هم نمایش داده نمیشه