public function init()
 {
     parent::init();
     if ($this->model == null) {
         $this->model = new \msdie\modules\comments\models\CommentForm();
         //            $this->model->url=\Yii::$app->request->absoluteUrl;
     }
     if ($this->conditionLinkParams == null) {
         $this->_comments = Comments::find()->where(['comments_link.url' => \Yii::$app->request->absoluteUrl, 'status_id' => 1])->joinWith('commentsLink')->all();
     } else {
         $this->_comments = Comments::find()->where(['comments_link.link_params' => $this->conditionLinkParams, 'status_id' => 1])->joinWith('commentsLink')->all();
         if ($this->linkParams == null) {
             $this->linkParams = is_array($this->conditionLinkParams) ? $this->conditionLinkParams[0] : $this->conditionLinkParams;
         }
     }
     $this->_action = Url::toRoute(['/comments/default/add', 'url' => \Yii::$app->request->absoluteUrl, 'link_params' => $this->linkParams]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Comments::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     $query->joinWith('commentsLink');
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'status_id' => $this->status_id, 'parent_id' => $this->parent_id]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'text', $this->text])->andFilterWhere(['like', 'comments_link.url', $this->pageUrl]);
     return $dataProvider;
 }