Closed eduardo-g-silva closed 7 years ago
Hi, relatedTo
column only used for filtering the comments in the admin panel.
Ok, so how do I show only the comments related to an specific activeRecord or url ?
Is it a way?
Show comments for specific model
:
$model = PostModel::find()->where(['title' => 'some title'])->one();
Comments will be attached for this model.
<?php
$model = PostModel::find()->where(['title' => 'some title'])->one();
echo \yii2mod\comments\widgets\Comment::widget([
'model' => $model,
]);
?>
Also, you can create you own dataProvider
and pass it to CommentWidget.
I prefer the first example.
It is working fine, looks like is not my day for programming.
If i provide the correct model it works as you said. It is a complex form and i was using another variable that i use for related books instead of the activeRecord.
Thanks again
You're welcome.
Hi Igor, Sorry to bored you with a silly question but I cant manage to filter the record comments all rest it is looking beautiful.
I can see that I can change the relatedTo property with any value and this change the db field but I don't understand how the model in my case $book works with the widget
thanks