When I’m retrieving data from an AR object, I want to dynamically create some attributes that are returned along with the data from the DB. I used the method afterFind() for this. This works fine but I recently noticed, it does not work when using $model->search(). I’ve tried all kind of other methods, but I couldn’t find one that works on all cases.
So which method could I use that is always executed when fetching data from an AR object?
The virtual attributes are created based upon existing attributes, for example, the URL’s of the corresponding images. This way, I can just get the thumbnail URL from the AR model when using gridview.
I’m not sure if I can use getters inside a gridview.