A
A
Anchor002015-08-23 23:32:56
Yii
Anchor00, 2015-08-23 23:32:56

Yii2, why doesn't search model work?

With the help of GII, CRUD was created. The search model, controller, and views have been created. In the controller, in actionIndex (read) the following code:

$searchModel = new ProductSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);

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

Those. As far as I understand, by passing parameters to search() we will filter. I pass the parameters (I check Yii::$app->request->queryParams, there are parameters in it, everything is OK, for example id=2, type=mfu), however, the dataProvider displays ALL products, not by filter. What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Belikov, 2015-08-24
@Anchor00

How should it work.
Can you please provide more model code and search model code.
Most likely, you have incorrectly described search conditions in your search model, or you are trying to use non-existent fields.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question