Saving Data Via Form In Two Different Models

Hey iam new to yii…

i have encounter a situation where i need to create a controller which has its view named index and code goes as follows…




<?php echo $this->renderPartial('_form', array('user'=>$user, 'order'=>$order,)); ?>



in _form code is




$form=$this->beginWidget('CActiveForm', array(

                	'id'=>'checkout-form',

                	'enableClientValidation'=>true,

                	'clientOptions'=>array(

                		'validateOnSubmit'=>true,

                	),

                    'enableAjaxValidation'=>true,

                )); 

                 echo $form->errorSummary(array($user,$order)); 

                ?>

            <table class="form">

              <tbody>

                         <tr>

                  <td><?php echo $form->labelEx($user,'name'); ?></td>

                  <td><?php echo $form->textField($user,'name'); ?></td>

                  <td><?php echo $form->error($user,'name'); ?></td>

                </tr>

                <tr>

                  <td><?php echo $form->labelEx($user,'email'); ?></td>

                  <td><?php echo $form->textField($user,'email',); ?></td>

                  <td><?php echo $form->error($user,'email'); ?></td></tr>

<tr>$form->hiddenField($order,array('value'=>$products[$x][0])</tr>/*data to be used in order model*/




in controller code goes as




public function actionIndex()

	{

	    $user=new User;

        $order=new Order;

        

        if(isset($_POST['user'], $_POST['order']))

        {

            // populate input data to $user and $oder

            $user->attributes=$_POST['user'];

            $order->attributes=$_POST['order'];

     

            // validate BOTH $user and $oder

            $valid=$user->validate();

            $valid=$oder->validate() && $valid;

     

            if($valid)

            {

                // use false parameter to disable validation

                $user->save(false);

                $oder->save(false);

                $this->redirect('menu/index');

                // ...redirect to another page

            }

            

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

                'user'=>$user,

                'error'=>$var,

                ));

        }

	  

      	}



Their are two Models User and Order this is where i want to save the data…

But it is not working it gives no error… but from is not submiting… what is wrong in this code plz tell me plz plz plz :unsure: :unsure: :unsure:




 $valid=$oder->validate() && $valid;



is this a typo ($oder)?

this may help you http://www.yiiframework.com/forum/index.php/topic/39052-save-same-data-in-two-model/page__p__187632__hl__two+Model+#entry187632