Why doesn't the filter by field in a GridView?

Hi, it's me again..

screwed searchModel to the gridView:
public function actionIndex() {

 $dataProvider = new ActiveDataProvider([
 'query' => User::find(),
 'pagination' => [
 'pageSize' => 1,
],
]);

 $searchModel = new UserSearch();


 return $this->render('index', [
 'dataProvider' => $dataProvider,
 'searchModel' => $searchModel,
]);

 }


But for some reason when you enter text and send the data arrives, the same that was without taking into account the entered text.
ab98ad8b9515c01b1b673.png

Can as that on another it is necessary to declare searchModel?
June 10th 19 at 14:59
1 answer
June 10th 19 at 15:01
Solution
Not looking for You because after you create a search and do not cause
$dataProvider = $searchModel->search(Yii::$app->request->get());

And DataProvider form do not need in the controller, it is formed in the search model.
And generally itself search model would do well to attach to the issue.
Search model did not give an example because it's a standard class generated CRUD'ohms.

Thanks, your example helped. was replaced by:

$searchModel = new UserSearch();
 $dataProvider = $searchModel->search(Yii::$app->request->get());

 return $this->render('index', [
 'dataProvider' => $dataProvider,
 'searchModel' => $searchModel,
 ]);


only pagination was off and displayed all at once, it is necessary to specify probably somewhere in the search method? - audrey_Kautz commented on June 10th 19 at 15:04
,
$dataProvider = $searchModel->search(Yii::$app->request->get())
$dataProvider['pagination']['pageSize'] = 1;
- bryana.Renn commented on June 10th 19 at 15:07
, Cannot use object of type yii\data\ActiveDataProvider as array
:( - audrey_Kautz commented on June 10th 19 at 15:10
sorry blunt, there is an object
$dataProvider->pagination->pageSize = 1 - bryana.Renn commented on June 10th 19 at 15:13
thank you very much! - audrey_Kautz commented on June 10th 19 at 15:16

Find more questions by tags Yii