I have a CGridView and I am trying to display the name of a record thru a foreign key. However that foreign key may not always be populated. So if I do $data->foreignKeyId->name I get the error "Trying to get property of non-object" because no object was found because the key was empty, which is not an error in itself.
How do I check if the foreign key is not null before trying to get the value of the associated record?