Batch Insert/create

Hello Everyone,

It seem like no one has successfully implemented Batch Insert with yii.

What am trying to achieve is related to this.

But in my own case, i want to insert multiple rows in which the fields are generated dynamically.

My models are attached. Please kindly help I have spent 24 Hours on this problem without a solution

[size="6"]This is my View[/size]


         foreach($datas as $key=>$data) {


      <fieldset style="border:none;">


           <h3 style="color:#777"><?php echo $data->title?></h3>

	<?php echo $form->hiddenField($model,"[$key]title", array('class'=>'span8','value'=>$data->title)); ?>

        <?php echo $form->html5EditorRow($model, "[$key]content", array('id'=>'ctn'.$data->id,'class'=>'span3', 'rows'=>16, 'height'=>'200', 'options'=>array('color'=>true))); ?>

            <?php echo $form->hiddenField($model,"[$key]template_id",array('value'=>$data->id)); ?>



  <?php } ?>

[size="6"]My Controller Action[/size]

public function actionCreate()


	$model=new Rfp;

            $datas = Template::model()->findAll(array("order"=>'id ASC'));



                if(isset($_POST['Rfp']) && isset($_POST['send'])) {


                    foreach($_POST['Rfp'] as $j=>$model) {

                        if(isset($_POST['Rfp'][$j])) {

                            $model=new Rfp; // if you had static model only


                            $models[] = $_POST['Rfp'][$j];

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



                    if($valid) {

                         foreach($models as $v)


                                    $v -> save();