Render 2 models

Hello!

first of all, sorry for my English.

This is my first post in this forum. Please, any ideas are welcome because I am not an expert using PHP and Yii.

I would like to know if it is possible to send two equals models from the controller to the view and then get attributes using something like this.




MyController{


....


$a = new myModel();

$b = new myModel();


//please, notice that $a and $b are two objects with the same configuration.


if(isset($_POST['ATTRIBUTES FROM THE FIRST MODEL']))           //This line and the next if are my doubt

{

 ...

}

if(isset($_POST['ATTRIBUTES FROM THE SECOND MODEL']))

{

 ...

}


render('page', array(

                 'model_A' => $a, 

                 'model_B' => $b, ))


...


}



thank you in advance!

you should read this wiki render two models in one view

Thank you yiqing95 but my problem is that both are the same model and in this article are different




    $a=new A;

    $b=new B;

    if(isset($_POST['A'], $_POST['B']))

    {



i think you mean batch creating ? :lol:

see Collecting Tabular Input

you should note this line : $items=$this->getItemsToUpdate();//this is for update ,similar to create

there 's no example for that , but you can search it in forum ;

or test yourself :




 getItemsToCreate($count=2){

             $items = array(); 

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

               $items[] = new MyModel();


             }

           return $items;


}