CDetailView. Attribute conditional display

Hi,

using a CDetailView, I am trying to display an attribute if it’s not null.

What happens is that, if it’s not null, the widget displays OK but if it’s null I get an error saying “Trying to get a property of non-object”.

I followed a previous thread with no success.

Any idea on how to fix this is appreciated.

Thank you.

It happens for property of related models, usually.


'value'=> ($model->relatedId)?$model->related->name:'-'

zaccaria,

thanks, it worked fine.

Thanks Zaccaria,

Nice solution… =)