Display Data from table with relation

I understand how to display data with a relationship in the CDetailView and I have no issues with it. However, I do not want to display this piece of the data in a data array. I want to display it by itself with some html.

I understand and get these to work:

<?php echo $model->field1; ?>

<?php print $model->field1; ?>

But I can’t get this to work, I get the error Object of class could not be converted to string

<?php echo $model->field1.relatedfield; ?>

In the data array it works but not by itself. Should I be doing something to it to convert it to a string before I echo it?


i think you could use this:

<?php echo $model->relationName->field1; ?>

where relationName is the name of the relation in your model.

Thanks so much, I don’t know how I missed that in the documentation.