Skip to content

Commit ccde8dc

Browse files
author
Igor Chepurnoy
committed
make the pjaxContainerId property as public
1 parent 5cdf33f commit ccde8dc

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,11 @@ echo \yii2mod\comments\widgets\Comment::widget([
105105

106106
echo \yii2mod\comments\widgets\Comment::widget([
107107
'model' => $model2,
108-
'formId' => 'comment-form2'
108+
'formId' => 'comment-form2',
109+
'pjaxContainerId' => 'unique-pjax-container-id' // also you can set the `pjaxContainerId`
109110
]);
110111
```
111112

112113
#### Example comments
113114
-----
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")

widgets/Comment.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ class Comment extends Widget
3737
*/
3838
public $formId = 'comment-form';
3939

40+
/**
41+
* @var string pjax container id
42+
*/
43+
public $pjaxContainerId;
44+
4045
/**
4146
* @var null|integer maximum comments level, level starts from 1, null - unlimited level;
4247
*/
@@ -72,11 +77,6 @@ class Comment extends Widget
7277
*/
7378
protected $encryptedEntityKey;
7479

75-
/**
76-
* @var string pjax container id, generated automatically
77-
*/
78-
protected $pjaxContainerId;
79-
8080
/**
8181
* Initializes the widget params.
8282
*/
@@ -86,7 +86,10 @@ public function init()
8686
throw new InvalidConfigException(Yii::t('yii2mod.comments', 'The "model" property must be set.'));
8787
}
8888

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+
9093
$this->entity = hash('crc32', get_class($this->model));
9194
$this->entityId = $this->model->{$this->entityIdAttribute};
9295

0 commit comments

Comments
 (0)