I used the CRUD generator in Yii2 and it generated the following code for my controller actionIndex...
public function actionIndex()
{
$searchModel = new LeadSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
I am trying to do two things for this code by default:
1) Set the page size so that the grid display displayed on it displays only 10 lines
2) Change it $searchModelso that it returns only records where the status column in the table corresponds to some several values (IN operator) ... or better yet, all records that do not match the given value.
For # 1, I see many examples for setting "pagination" when used ActiveDataProvider, but not for search(). This code did not work for me ...
$dataProvider = $searchModel->search(
Yii::$app->request->queryParams, ['pagination' => [ 'pageSize' => 10 ]]
);
For # 2, I know that we can filter by declaring a new LeadSearch object as ...
$searchModel = new LeadSearch([ 'status' => 'open' ]);
... - ...
$searchModel = new LeadSearch([ 'status' => ['open', 'pending'] ]);