Virtual attribute (search & filter)


(Kavitama) #1

All the mechanism of virtual attributes is very clear to me and also the search filter thing which is working quite well in every project I had to work with but this is a special situation which I am not able to solve.

Imagine a vehicle table with, just to simplify, 3 columns: id, description and owner.
This table can be view by all the users, no matter if they are owners or not but of course only owner can change attributes of their vehicles.

So I created a virtual attribute that is simply set to Yes or No if the owner is equal to the user id.
The virtual attribute is set correctly but if I want to use it as a filter in a grid view since the column is NOT a real DB column any attempt to use CDBCriteria search is going to blame on me because that Yes/No column is not a DB column.

I know I can check user id to decide which action can be accepted on each vehicle but I need to show a Yes/No column so people can decide to filter which vehicles they want to see.

How can this be solved?