Reputation: 5755
I want to make a custom getter that should return two fields of the model instead of one. I have the attribute name like first_name
. And the getter I am making is
public function getFirstName(){
return 1;
}
And then I try to get it called in a CDetailView like this
'client.first_name:raw:Client',
But it returns the standard attribute of the model. How to do it right?
Upvotes: 3
Views: 234
Reputation: 5955
Yii's order of operations to retrieve an attribute is as follows:
I'm not sure whether AR attributes or public variables are pulled first, but I do know that if either of them exist, your custom getter won't be called.
If you already have a first_name attribute (from AR), then you'll need to use a different name for your getter and use that.
Upvotes: 2