with(['post']); $dataProvider = new ActiveDataProvider([ 'query' => $query, 'key' => function (BlogComment $comment) { return [ 'post_id' => $comment->post_id, 'id' => $comment->id, ]; }, 'sort' => [ 'defaultOrder' => ['id' => SORT_DESC] ] ]); $this->load($params); if (!$this->validate()) { $query->where('0=1'); return $dataProvider; } $query->andFilterWhere([ 'id' => $this->id, 'post_id' => $this->post_id, ]); $query ->andFilterWhere(['like', 'text', $this->text]); return $dataProvider; } public function activeList(): array { return [ 1 => Yii::$app->formatter->asBoolean(true), 0 => Yii::$app->formatter->asBoolean(false), ]; } }