I have a problem here. Basically what I’m trying to do is to add users to an event. To see if a user is already added to an event, I created a little method that fetches the IDs of all previously added users and returns an array. What I intended to do was to pass that array to my view file and check on the fly if the ID of the respective user in my CGridView is in that array via phps in_array function and ultimately displaying an add link or not. But it doesn’t work at all because I can’t access the variable of my array within the ‘value’ part of my column.
Is there any way to do this? Or any other suggestions how to realize this?
You can do it the other way around by having you event model have a function that checks if current user is member of the event for each row in the CGridView.
In CGridView you can access the events by using the $data variable. Example:
Thanks for the reply! I’m aware that I can do it by querying the database over and over again, but it think it would be much leaner to query it just once and store the IDs?!
I just solved it in the way it is described in the wiki above. Extended the CGridView class and added a parameter for the array, so I was able to access it via $this->grid.