Shankar
Shankar

Reputation: 41

Avoid to list all records on empty search in YII Admin page

In YII admin page (CRUD), by default all the records of the table will be displayed when searching with empty data in all fields.

But i need to avoid the default list. Instead, some data need to be entered in filter text box. Then only search result should shows the result based on the input. Otherwise no record should displayed.

Thanks in advance.

Upvotes: 0

Views: 248

Answers (1)

topher
topher

Reputation: 14860

In the search function for your model replace the $criteria->compare(.... with CDbCriteria methods that add the same condition. The compare method is the only one that doesn't add a condition expression to the criteria if the attribute is empty.

Upvotes: 1

Related Questions