Daunio
Daunio

Reputation: 61

Yii2 - Get filtered values

I know this could be an unusual request but I hope someone can help me.

In my gridview, I need to get the filter's values, for example, if I select a specific date to display at my gridview as filter, I want to get the date selected, my goal is to be able to make a query with all filters. I do not know if there is a way to do it.

enter image description here

Thanks :)

Upvotes: 0

Views: 1395

Answers (1)

Tibor Nagy
Tibor Nagy

Reputation: 1236

You can access the filter values in your controller. In the example below use your filter field name index in the place of myFilterName.

public function actionIndex($indexDeleted=false)
{
    $queryparams = Yii::$app->request->queryParams;
    $myDateValue = isset($queryparams['myFilterName']) ? $queryparams['myFilterName'] : null;

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

Upvotes: 1

Related Questions