Forms of 2 models in one form

Hi all,

I have 2 seperate models models1 and model2. What i want to know is, is it possible to have the forms of both those models combined in one form and then save their values individually?If so how do i go about this?

Start by reading this wiki - http://www.yiiframework.com/wiki/19/how-to-use-a-single-form-to-collect-data-for-two-or-more-models

hi mdomba,

thanks for the reply. What you said has to be done in the controller but what i want to know is how do i combine the 2 forms inside one form and display it?

Please help me…

Thanks

Have you read the wiki?

If yes… do you understand that you can create two models and send them both to the view with




$this->render('create',array(

   'model1'=>$model1,

   'model2'=>$model2

));



Now in the view you have 2 models: $model1 and $model2… and you can create input fields for both of them…

NOTE: you posted in the Yii 1.0 sub.forum… do you use this version ?

hi, i want to ask u, i want to save one textfield into two different table, how can i do that?