That is to say, if you have the function getName() as a method of your model, you should be able to treat ‘name’ as simply another attribute of the model, so $model->name should return the results of the getName() method. Not only this, but you can also add an entry to the attributes names array to give your method a friendly name, like ‘name’ => ‘Primary Insurance ID’.
These should both then be taken into account automatically when you add name as a normal attribute column:
…
‘patient_ssn_3’,
‘patient_medcare_no’,
‘patient_medcaid_no’,
‘name’,
…
This works for me in CGridview anyway - I have one model which has two separate attributes - a path and a file name; in the model I have added a function getFullPath(), as well as an entry to the attribute names - ‘fullPath’ => ‘Full Path’;
and in my CGridView columns array I just add the line ‘fullPath’, and it all works!
I just pointed to the author of the post where he made the error… and as the post title is "call a method in…"… I wanted to show how any method can be called from CGridView…
But is it possible to create a filter on a magic method variable? For example, I have a table of events with displayed_start_date and displayed_end_date, and I have a method in my model called getIsVisible(). I’d like to have a column in CGridView called Visible?, which calls my magic isVisible getter variable.
I’ve tried many ways of accomplishing this — declaring public $isVisible in the model, making sure the variable is in the search rule, etc. — but I keep getting errors.