I would like to display a comment form below each post in a multi-post index view, but can’t figure out how to structure this in a proper MVC way. My actionIndex function would be the logical place to create the new comment but this would only pass one comment to the entire dataProvider:
$dataProvider = new CActiveDataProvider('Post',array('sort'=>array('defaultOrder'=>'create_time DESC',),'pagination'=>array('pageSize'=>10,'pageVar'=>'page')));
$comment = new $comment;
$this->render('index',array(
'dataProvider'=>$dataProvider,
'comment'=>$comment,
));
Thanks for your reply, but maybe I’m missing something? The tutorial seems to cover how to add a comment form to the single post view. But I would like to have a form under each post in a multi-post view. So my page would look like this:
POST #1
COMMENT #1
COMMENT #2
COMMENT #3
COMMENT FORM
POST #2
COMMENT #1
COMMENT #2
COMMENT FORM
POST #3
COMMENT #1
COMMENT #2
COMMENT FORM
Trouble is I can’t seem to create the comment form without attaching it to a specific post. But when I use CActiveDataProvider to display a paginated list of posts, where would I create the comment?
Should it be possible to post multiple comments to multiple post via a "master submit button" or partial via AJAX.
OR
Should it be only possible to create one comment to one post?
With the first one you need some kind of tabular input handling.
With the second you could e.g. create one comment form for all posts but show it only on the current post/comment via mouseover. With this solution you know to which post the comment belongs cause you know where you have inserted the comment form in the DOM (via javascript).
i have created a recent activity wall but it uses pure html and jQuery ajax i was having issues with using yii ajax and forms here is what i had done i guess u are going the same thing