urgent SEARCH / FILTER problem

Hi Folks,

Please help me in my search / filter problem.

I have a model, and a method in my model. It’s simply retuns a new CActiveDataProvider after I set the CDbCriteria. In criteria there are some variables, which is not the part of the AR, because they are ALIAS fields eg: (SUM(xyz) etc…)

I made some pubic variable for my model, to use this in my query.

In my view file I use CGridView to represents these datas. It works correctly, fut the SEARCH / FILTER fields not.

If i try to filter the result nothing happens, but the GET send the params correctly - I see it on firebug params tab.

It send my own variable, and in the controller there is a setting row:

$dataProvider = new MyModel('myFunction');



$dataProvider->attributes = $_REQUEST['MyModel'];


… but it seems to me that “$dataProvider->attributes” doesn’t save my variables to the model…

I tried to get answer by google but i gave up after a day…

PLEASE someone tell me how can I solve this problem!!!

Read the guide about "safe" attributes…

Hmmm, and than? I really did’t find anything, what helps me :(

Safe attributes are in effect when you use one massive assignment. If in doubt, try assigning attributes one by one, just to check if your assumption is correct.

Since you named the model instance $dataProvider, perhaps this post may point you in the right direction.


Thanks Tommy for answer.

I read the post you sent… I think my code is correct.

I suppose that my problem about the part of the attributes save. In my model method, when I try to print_r $this->attributes or $this->attributeNames it lists just the original array items.My public variables aren’t in the array.

If you have read about the "safe" attributes… than you would know that you need to declare the validation rules for your model…

so what are your rules?