noob question about "relations()"

Hey guys,

im new to this forum and more or less to yii. After working through the (really great written Yii book) I now started to make my own first little web project.

And so far i must say - i LOVE Yii ;-). It’s exactly what i was looking for.

But now i got a little noob problem and just cant figure out how to solve this.

I’m actually working on something like a blog, where lots of languages will be available.

I was planning to do it like this:

Table "entry" with fields like type, create time, update time, status etc etc.

But the "content" of an entry will be stored in table "translation". other stuff like the title, language code etc will be stored in this table as well.

What i want to do now is the following:

when for example creating an entry, i want the create form contain the "content" fields stored in the "translate" table as well of course. what do i have to do, to make this work?

In the Entry::relations method I configured the relation to the translate table like the following:

'translations' => array(self::HAS_MANY, 'Translation', 'entry_id',

                'condition' => 'translations.language_code=' . Translation::USER_LANGUAGE),

in the index.php of the entry view i tried something like this:

	<div class="row">

		<?php /*echo $form->labelEx($model->getTranslation($model),'language_code'); ?>

                <?php echo $form->dropDownList($model->getTranslation($model),'language_code',  Translation::getTypeOptions()); ?>

		<?php echo $form->error($model->getTranslation($model),'language_code'); */?>


the getTranslation() Method just gives back the entry of the translation table I need:

public function getTranslationObject($entry)


        return $entry->translations;


but it just doesn’t work. Do i have to think of anything else, or is the above code just crap? :wink:

Thanks for your help guys,


------------------------- EDIT -------------------------------

this is the error i keep getting:

"get_class() expects parameter 1 to be object, array given "

how can I call it as an object? … maybe Im just too blind right now …

Assuming one record will be returned, this probably would work (supplying initial value and resolve class name for generating the element id)

  return $entry->translations[0];


Ohh my god :-D. Thanks a lot mate! … good to know that I’ve been on the right path ;-).