Problem With Batch Updating

i want to use batch updating and implement this code:

PostsController methods:




public function actionBatchUpdate()

	{

	   $models=null;

       $ids=null;

		if(isset($_POST['ids']))

        {

            $ids=$_POST['ids'];

            $models=$this->loadModels($ids);

        }


		// Uncomment the following line if AJAX validation is needed

		// $this->performAjaxValidation($model);

        

		if(isset($_POST['Posts']))

		{

            $isValid=true;

			foreach($models as $i=>$model)

            {

                if(isset($_POST['post'][$i]))

                {

                    $model->attributes=$_POST['Posts'][$i];

        			if($model->save())

                        $isValid=$isValid && true;

                }

    				

            }

            if($isValid)

                $this->redirect(array('index'));

		}

        

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

			'models'=>$models,

            'ids'=>$ids,

		));

	}

	public function loadModels($ids)

	{

	   $ids=preg_split('/\s*,\s*/',trim($ids));

		$models=Posts::model()->findAllByPk($ids);

		if($models===null)

			throw new CHttpException(404,'The requested page does not exist.');

		return $models;

	}



batchUpdate view:




<div class="form">


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

	'id'=>'posts-form',

	'enableAjaxValidation'=>false,

)); ?>


    <input type="text" name="ids" />

    

    <?php if(isset($models)) { ?>

    

	<p class="note">Fields with <span class="required">*</span> are required.</p>


	<?php foreach($models as $i=>$model) { ?>

    

    <?php echo $form->errorSummary($model); ?>


	<div class="row">

		<?php echo $form->labelEx($model,"[$i]title"); ?>

		<?php echo $form->textField($model,"[$i]title",array('size'=>60,'maxlength'=>511)); ?>

		<?php echo $form->error($model,"[$i]title"); ?>

	</div>


	<div class="row">

		<?php echo $form->labelEx($model,"[$i]content"); ?>

		<?php echo $form->textArea($model,"[$i]content",array('rows'=>6, 'cols'=>50)); ?>

		<?php echo $form->error($model,"[$i]content"); ?>

	</div>

    

    <?php } ?>


	<div class="row buttons">

		<?php echo CHtml::submitButton('Save'); ?>

	</div>

    

    <?php } ?>


<?php $this->endWidget(); ?>


</div><!-- form -->



everything is ok and fields are populating with correct attributes of model but when i want to update some of them there is no effect on data. any suggestion?

thanks in advance

Controller:

public function actionBatchUpdate()

                              {


       &#036;model= new ModelFrom;


            if(isset(&#036;_POST['ViewName']))


    {


              &#036;model-&gt;MyPublicFunctionModel();


             &#036;models = &#036;this-&gt;render('batchUpdate',array(


                    'models'=&gt;&#036;models,


        'ids'=&gt;&#036;ids,


            ));





    }

}

Model

class PruebaForm extends CFormModel

{

public array1;


public array2;

public class MyPublicFunctionModel(){

if(isset($_POST[‘ids’])){

 &#036;data = //array data    //exectute query    //sql

}

if(isset($_POST[‘Posts’])){

&#036;data = //array data    //exectute query    //sql

}

return $data;

}

}

and view

foreach($models as $model){

 echo &#036;model['NameRes']['NameRes']; 

//or

echo &#036;model['rowname']; 

}

i don’t understand your code, are you change the model? i think this is not necessary.can you explain more?

in my code somewhere near saving model after submit form is wrong(in controller). can anyone help me where is the problem?