CGridView - don't show default results

Apologies if you’ve seen this before. I posted it a couple of days back but now can’t see it in the forums!!??

I have a gridview on my Yii admin page for searching but because the view is displayed by default with the model, a search is carried out with empty text boxes and which returns all rows in the model. I don’t want this because 1) there will be thousands of entries by default which would not be useful (even if limited) and 2) It would mean the people at the top of the list might get selected frequently by mistake.

I want the results NOT to appear when the page is first impressed and the search to require at least one search term to be filled in.

Is there any way I can do this without a big ‘if’ statement in the search function of my model?


In your view, check if user has submit search form, only then display the grid, Don’t display grid if model attributes are empty.

Is there a way to find out if a model attributes are all empty without large ‘if’ statement?