Multiple Insert To Model

Hello everyone, I need your help.

I need to insert 2 records in the same time to table therefore I made my _form.php as the following:




	<div id="hor">

		<?php echo $form->labelEx($modell[0],'[0]fromplace'); ?>

		<?php echo $form->textField($modell[0],'[0]fromplace',array('size'=>20,'maxlength'=>40)); ?>

		<?php echo $form->error($modell[0],'[0]fromplace'); ?>

        </div>

	<div id="hor">

        

		<?php echo $form->labelEx($modell[1],'[1]fromplace'); ?>

		<?php echo $form->textField($modell[1],'[1]fromplace',array('size'=>20,'maxlength'=>40)); ?>

		<?php echo $form->error($modell[1],'[1]fromplace'); ?>

        </div>



In Create I do the following:


               if(isset($_POST['Extra'][0]))

                        {

                              $model2->attributes=$_POST['Extra'][0];

                              $model2->extraid=$model->id;

                              $model2->save();

        

                        }

                   if(isset($_POST['Extra'][1]))

                        {

                              $model2a->attributes=$_POST['Extra'][1];

                              $model2a->extraid=$model->id;

                             $model2a->save();

        

                        }



sometimes I leave one of the field empty so I added to beforesave()




 public function beforeSave()

        {

                if(parent::beforeSave())

                {

                        if ($this->fromplace=="")

                                return false;

                   

                }

        return true;

        }



the create action is working properly but the problem with update because of one of the field is not filled so the update page is not loaded properly.

how can I solve this issue.

I think the you can find the answer to your question here

http://www.yiiframework.com/doc/guide/1.1/en/form.table