gets the value of the property "detail" from the object $model - $model is an OBJECT
$model['detail']
gets the value of the element "detail" from the array $model - $model is an ARRAY
…
When you say sometime it works and sometime not… it’s always with the same relation or there are different relations in question? or even some model attributes?
About another possibility with this very same error:
The same error message happened to me when I was trying to set the CActiveRecord Attributes array.
So I discovered another method to overcome this issue, in a case where the magic method is related to an object variable which contains an array take a look: you create an AUXILIARY ARRAY in which you put the original and the new values (sometimes one wants to REPLACE a value related to one of the keys, and these methods are not satisfactory). And AFTERWARDS use an assignation, which works like the reference. For example, in the next example, I generalize $model->attribute to
"Object->array_built_with_magic", but I used it first with $model->attribute. Take a look:
$auxiliary_array = array();
foreach(Object->array_built_with_magic as $key=>$value) {