What is the best approach to trigger a search in a GridView with default params values.
EG:
$searchModel = new MyModelFilter(['status'=> MyModel::STATUS_ACTIVE]);
$dataProvoder = $searchModel->search(Yii::$app->request->getQueryParams());
First line will not trigger the search when using search filter generated by Gii. The main reason is that the form is not submitted hence $this->load($params) returns false in the below code ($params being empty).
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
So whould you do to have filter defaults values and triggering the search without user action (knowing that the user can modify the default value, eg: filtering the grid on a different status value).
For the record, I know I can modify the request query params to manually add the default value but, conceptually, I think it is better to modify the model filter instead of the user submitted params.