Passing data to view

i crated a function inside the controller:


public function cats() 	{ 		

$criteria=new CDbCriteria; 		


return $mymodel; 		 	


then i called the function inside the actionCreate:


the problem when i tried to send $mymodel to the view with:

$this->render(‘create’,array(‘model’=>$model, ‘mymodel’=>$mymodel));

i get nothing from the $mymodel … (( Invalid argument supplied for foreach() ))

any help please

You must have a typo somewhere as findAll always returns an array. So maybe do a


before the render line to verify the real content of $mymodel.

try like this:

public function cats()  {               


return $mymodel;                        


Thanks Mike

i did that already before render and it works for me … i can access the data with this code:

foreach($mymodel as $n=>$cmodel):

echo $cmodel->cat_paid;


but i can’t pass it to the view with the above rendering


the same result and actually i do have criteria conditions but i wrote it here as simple as i can …

It can only be a typo otherwhise it would work ;)

Did you check upper/lower case of your variable names?

thank you guys:

the problem is that i tried to access the $mymodel from the _form which i can’t do unless i passed the $mymodel from the create view again to to the partial view with $this->renderPartial …

sorry misguiding and thank you