I’m sure that this is simple but I can’t find an answer. I have a generic model called Clients for which I am viewing the records with client/admin. However I want to apply a WHERE clause to only return records where an attribute is a given value. I’m not sure what or where I need to make this change. Is it a change I need to make inside the actionAdmin() or elsewhere?
I have read the post but am still lost on how to achieve this. I don’t want to change anything in the view. I believe I should be able to filter the results in the model or controller for the given attribute.
Can I not do something in the method actionAdmin() like this?
OK, I have to be more specific. Using the term filter was not a good example as you can filter the results within the view.
From the start:
By default, the actionAdmin() method will return all results for the given model and then pass these results to the view to be displayed. For this model (Client) there is one attribute named businessId. What I want to do is have actionAdmin() pass records for Client where the businessId was equal to 1 for example. I am retrieving the value OK but I don’t know how or where to implement the condition.
I thought the search method was only for search or advanced search when in the view. I didn’t realise you can use it to do what I wanted. That search method wasn’t available in the version of Yii that I had been using previously. I must look into that.