Renderpartial Within A Rendered View - Variable Not Defined


I’m trying to display a form to create a new Donations within a view that renders Campaigns or rather a single campaign…

It worked fine displaying the Campaigns data passed to the view, but when I added the code to renderPartial I keep getting a PHP notice "Undefined variable: donations".

In the CampaignsController i am using this code:

	public function actionDisplay($id)




		$params = array('User_ID'=>$campaign->campaign_user);

		if(Yii::app()->user->checkAccess('displayCampaigns') || Yii::app()->user->checkAccess('displayOwnCampaigns',$params)){








			$parts = $this->parts;







		} else {

			throw new CHttpException(403,"You can only display your own Campaign");			



here is the function createDonations() which is also in CampaignsController, and is called by $donations=$this->createDonations($campaign);

	protected function createDonations($campaign) {

		$newdonation = new Donations; 

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


			if($issue->addDonations($newdonation)) {

				Yii::app()->user->setFlash('donationsSubmitted',"Your Donation has been added." );





		return $newdonation;


In the layout campaignlayout1 I first render data from $campaign and $parts. That worked fine, so I then added a renderPartial() to display the _form from Donations

here is that code:

	<?php $this->renderPartial('/donations/_form',array(

		'model'=>$donations, )); ?>

I get a PHP notice: Undefined variable: donations

here is a portion of the stack trace:

/protected/controllers/CampaignsController.php(232): CController->render("display", array("model" => Campaigns, "parts" => array("banner" => "", "avatar" => "", "copy" => "<p> Send Money </p>", "campaign_name" => "Joes Fundraising"), "donations" => Donations))

Any idea what I’m doing wrong here??

What variable do you use in the view ‘/donations/_form’?

If you use $donations there, this is wrong, because you submit this as $model in renderPartial.