Active record, main criteria

(Pellicanipasquale) #1

Hi all, in my modelSearch I have a filter in the main query for select only record with [‘enabled’=>true], how can I use this filter in all searches without rewriting the condition where in each context every time?


(Andro) #2

By writing your own filter for your controllers or a behavior for models, which adds a where-clause to each query of the model?
You add this filter to your other model search classes.


(Softark) #3

Please check this section of the guide.

(Pellicanipasquale) #4

great was what i was looking for, thanks @softark

(Pellicanipasquale) #5

I have a model with its classic modelSearch only that the filter that I use in modelSearch I wanted to use it also in the main model without writing twice the same condition, here is what I was trying to do. thanks