create form with 2 model values

I have 2 tables categories and cat_lan (title for categories for each lanfuage -another table,english etc)

My problem is that I want to create a text field (cat_lan title) for each language at "new category form".

Now I can make 2 fields but have both the same "name" atributes so it is wrong.

What can I do?

I have done this


public function actionCreate()

    {....

 $cat_lan=$this->getlan();

...

}

...

 private function getlan()

    {

        $lans=   lans::model()->findAll();

        $cat_lan=array();

        foreach($lans as $key=>$value)

        { $cat_lan[$key]=new cat_lan;

            $cat_lan[$key]->lan_code=$key->lan_code;


        }

        return $cat_lan;

    }

and at form


 foreach ( $cat_lan as $key=>$value)

    {        

      echo    CHtml::activeHiddenField($key,"lan_code[$key]");     

        echo CHtml::activeTextField($key,"cat_name[$key]",array('size'=>60,'maxlength'=>255));

    }

but there is the error

at _form.php:20.

What is wrong?

I find a solution that worked at my first test,I thing I have to do something simiral at update.


public function actionCreate()

    {

        $model=new cats;

        $cat_lan=$this->getlan();


        if(isset($_POST['cats'],$_POST['cat_lan']))

        {

            $model->attributes=$_POST['cats'];

            $valid=$model->validate();


            foreach($_POST['cat_lan'] as $i=>$item)

            {

                $cat_lan[$i]->attributes=$_POST['cat_lan'][$i];

                $valid=$valid && $cat_lan[$i]->validate();

            }




            if($valid){//print_r($_POST['cat_lan'] );exit();

                $model->save(false);

                foreach($_POST['cat_lan'] as $i=>$item)

                {  $catlan=new cat_lan;

                    $catlan->attributes=$_POST['cat_lan'][$i];

                    $catlan->cat_id=$model->cat_id;

                    $catlan->save(false);

                }




                $this->redirect(array('show','id'=>$model->cat_id));

            }

        }

        $this->render('create',array('model'=>$model,'lan'=>$lans,'cat_lan'=>$cat_lan));

    }

_form.php


  <?php  if ($update==false){

       foreach ( $cat_lan as $key=>$value)

    {        

      echo    CHtml::activeHiddenField($value,"lan_code[$key]");

        echo CHtml::activeTextField($value,"cat_name[$key]",array('size'=>60,'maxlength'=>255));

    }

    }

    ?>