File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -105,10 +105,11 @@ echo \yii2mod\comments\widgets\Comment::widget([
105
105
106
106
echo \yii2mod\comments\widgets\Comment::widget([
107
107
'model' => $model2,
108
- 'formId' => 'comment-form2'
108
+ 'formId' => 'comment-form2',
109
+ 'pjaxContainerId' => 'unique-pjax-container-id' // also you can set the `pjaxContainerId`
109
110
]);
110
111
```
111
112
112
113
#### Example comments
113
114
-----
114
- ![ Alt text] ( http://res.cloudinary.com/zfort/image/upload/v1467214676/comments-preview.png " Example comments ")
115
+ ![ Alt text] ( http://res.cloudinary.com/zfort/image/upload/v1467214676/comments-preview.png " Example comments ")
Original file line number Diff line number Diff line change @@ -37,6 +37,11 @@ class Comment extends Widget
37
37
*/
38
38
public $ formId = 'comment-form ' ;
39
39
40
+ /**
41
+ * @var string pjax container id
42
+ */
43
+ public $ pjaxContainerId ;
44
+
40
45
/**
41
46
* @var null|integer maximum comments level, level starts from 1, null - unlimited level;
42
47
*/
@@ -72,11 +77,6 @@ class Comment extends Widget
72
77
*/
73
78
protected $ encryptedEntityKey ;
74
79
75
- /**
76
- * @var string pjax container id, generated automatically
77
- */
78
- protected $ pjaxContainerId ;
79
-
80
80
/**
81
81
* Initializes the widget params.
82
82
*/
@@ -86,7 +86,10 @@ public function init()
86
86
throw new InvalidConfigException (Yii::t ('yii2mod.comments ' , 'The "model" property must be set. ' ));
87
87
}
88
88
89
- $ this ->pjaxContainerId = ArrayHelper::getValue ($ this ->clientOptions , 'pjaxContainerId ' , 'comment-pjax-container- ' . $ this ->getId ());
89
+ if (empty ($ this ->pjaxContainerId )) {
90
+ $ this ->pjaxContainerId = 'comment-pjax-container- ' . $ this ->getId ();
91
+ }
92
+
90
93
$ this ->entity = hash ('crc32 ' , get_class ($ this ->model ));
91
94
$ this ->entityId = $ this ->model ->{$ this ->entityIdAttribute };
92
95
You can’t perform that action at this time.
0 commit comments