PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, March 6, 2022

[FIXED] Yii2 - Get filtered values

 March 06, 2022     filter, gridview, php, yii, yii2     No comments   

Issue

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 :)


Solution

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);
    ...


Answered By - Tibor Nagy
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing