How to pass array of object model from Controller to view

Hello ,I’m a newbie in yii.I want to pass array of object modle from controller to to view.This is my code

public function actionCreate() {

    if (isset($_GET['productId']) && isset($_GET['categoryId'])) {


        $countProperty = CategoryProperty::model()->count('categoryId=:categoryId', array(':categoryId' => $_GET['categoryId']));


        $model=array();


        for($i=0;$i<$countProperty;$i++){


          [size="4"][b] $model[] = new Productproperty;[/b][/size]


             


             


        }


        if (isset($_POST['Productproperty'])) {


          for($i=0;$i<$countProperty;$i++){


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


          }


          var_dump($_POST);


          exit();


            if ($model->save())


                $this->redirect(array('view', 'id' => $model->propertyId));


        }





        [color="#FF0000"]$this->render('create', array(


            'model' => $model,'countp'=>$countProperty


        ));[/color]


    }


    // Uncomment the following line if AJAX validation is needed


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


}

This a view ----------------------------------------------------------------

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

'id'=&gt;'productproperty-form',


'enableAjaxValidation'=&gt;false,

)); ?>

&lt;p class=&quot;note&quot;&gt;Fields with &lt;span class=&quot;required&quot;&gt;*&lt;/span&gt; are required.&lt;/p&gt;





&lt;?php echo &#036;form-&gt;errorSummary(&#036;model); ?&gt;

[color="#9ACD32"]<?php for($i=0;$i<$countp;$i++){?>

&lt;div class=&quot;row&quot;&gt;


	&lt;?php echo &#036;form-&gt;labelEx(&#036;model[&#036;i],'value'); ?&gt;


	&lt;?php echo &#036;form-&gt;textField(&#036;model[&#036;i],'value',array('size'=&gt;60,'maxlength'=&gt;255)); ?&gt;


	&lt;?php echo &#036;form-&gt;error(&#036;model[&#036;i],'value'); ?&gt;


&lt;/div&gt;











&lt;div class=&quot;row&quot;&gt;


	&lt;?php echo &#036;form-&gt;labelEx(&#036;model[&#036;i],'unit'); ?&gt;


	&lt;?php echo &#036;form-&gt;textField(&#036;model[&#036;i],'unit',array('size'=&gt;50,'maxlength'=&gt;50)); ?&gt;


	&lt;?php echo &#036;form-&gt;error(&#036;model[&#036;i],'unit'); ?&gt;


&lt;/div&gt;

<?php }?>[/color]

&lt;div class=&quot;row buttons&quot;&gt;


	&lt;?php echo CHtml::submitButton(&quot;Create&quot;); ?&gt;


&lt;/div&gt;

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

but I var_dump($_POST) in controller when view submit ,It only get the last object model in array.

Please help me.

Thanks you very much

Hi and welcome to the Yii forum…

First… note that you posted your question in the book section… .are you working on the code from the book ?

Second… when posting your code… to make it more readable… please use the code directive (<> on the editor toolbar)… you can even edit your post to add them ;)

And in the end… for your problem… check this part of the documentation - collecting tabular input - http://www.yiiframework.com/doc/guide/1.1/en/form.table