Answer the question
In order to leave comments, you need to log in
How to add to dataProvider searchModel?
There is this code in index
$searchModel = new QuestionSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('view_all_questions', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
$dataProvider = new ActiveDataProvider([
'query' => Question::find()->where('test_id=:test_id', array(':test_id'=>$test_id)),
]);
Answer the question
In order to leave comments, you need to log in
Note that stuffing the searchModel into the dataProvider is your idea. In fact, right here:
the result of executing the search method from the QuestionSearch object gets into the variable named dataProvider. And not stuffing the searchModel into the dataProvider. And if you look at what is in it (in the search method), then you will find just this or something like that:
$dataProvider = new ActiveDataProvider([
'query' => 'someQuery'
]);
return $dataProvider;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question