public function actionEdit()
 {
     $this->loadContentAddon(Comment::className(), Yii::$app->request->get('id'));
     if (!$this->contentAddon->canWrite()) {
         throw new HttpException(403, Yii::t('CommentModule.controllers_CommentController', 'Access denied!'));
     }
     if ($this->contentAddon->load(Yii::$app->request->post()) && $this->contentAddon->validate() && $this->contentAddon->save()) {
         // Reload comment to get populated updated_at field
         $this->contentAddon = Comment::findOne(['id' => $this->contentAddon->id]);
         return $this->renderAjaxContent(\humhub\modules\comment\widgets\Comment::widget(['comment' => $this->contentAddon, 'justEdited' => true]));
     }
     return $this->renderAjax('edit', array('comment' => $this->contentAddon, 'contentModel' => $this->contentAddon->object_model, 'contentId' => $this->contentAddon->object_id));
 }
Exemple #2
0
        <?php 
if ($isLimited) {
    ?>
            <?php 
    echo AjaxButton::widget(['label' => Yii::t('CommentModule.widgets_views_comments', 'Show all {total} comments.', array('{total}' => $total)), 'ajaxOptions' => ['type' => 'POST', 'success' => new yii\web\JsExpression("function(html) { \$('#comments_area_" . $id . "').html(html); }"), 'url' => Url::to(['/comment/comment/show', 'contentModel' => $modelName, 'contentId' => $modelId])], 'htmlOptions' => ['id' => $id . "_showAllLink", 'class' => 'show show-all-link'], 'tag' => 'a']);
    ?>
            <hr>
        <?php 
}
?>

        <?php 
foreach ($comments as $comment) {
    ?>
            <?php 
    echo \humhub\modules\comment\widgets\Comment::widget(['comment' => $comment]);
    ?>
        <?php 
}
?>
    </div>

    <?php 
echo \humhub\modules\comment\widgets\Form::widget(['object' => $object]);
?>

</div>
<?php 
/* END: Comment Create Form */
?>