Advertisement
krot

yii2 filterModel

Apr 4th, 2018
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1. class FilterCol extends Model
  2. {
  3. private $data=array();
  4. public function __get($name)
  5. {
  6.      if (array_key_exists($name, $this->data)) {
  7.             return $this->data[$name];
  8.         }
  9.    
  10. }
  11. public function rules() {
  12.    return [
  13.     /* your other rules */
  14.     [['nameGroup'],'default']
  15.    ];
  16. }
  17. public function search($params) {
  18.     print_r($params);
  19. }
  20. }    
  21.      
  22.      
  23. $searchModel=new FilterCol();
  24.  
  25. $searchModel->search(Yii::$app->request->queryParams);
  26.  
  27.  
  28.  
  29. or
  30.  
  31. 'filterModel'=>true,
  32. 'columns' => [
  33.             [
  34.                'label' =>"г",
  35.                'attribute' => 'nameGroup',
  36.                 'format'=>'raw',
  37.                 'filter' =>'<input class="form-control" name="filter[nameGroup]" value="'.Yii::$app->request->get('filter')['nameGroup'].'" type="text">'
  38.                 ,
  39.             ],
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement