Possible Duplicate:
PHP: “Notice: Undefined variable” and “Notice: Undefined index”
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)
    {
            $campaign=$this->loadModel($id);
            $donations=$this->createDonations($campaign);
            $params = array('User_ID'=>$campaign->campaign_user);
            if(Yii::app()->user->checkAccess('displayCampaigns') || Yii::app()->user->checkAccess('displayOwnCampaigns',$params)){
                    $this->parts=array(
                            'banner'=>Images::model()->getImageUrl($campaign->campaign_banner),
                            'avatar'=>Images::model()->getImageUrl($campaign->campaign_avatar),
                            'copy'=>$campaign->campaign_copy,
                            'campaign_name'=>$campaign->campaign_name,
                    );
                    $parts = $this->parts;
                    $this->layout='//layouts/campaignlayout1';
                    $this->render('display',array(
                            'model'=>$campaign,
                            'parts'=>$parts,
                            'donations'=>$donations,
                    ));
            } 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'])) {
                    $newdonation->attributes=$_POST['Donations']; 
                    if($issue->addDonations($newdonation)) {
                            Yii::app()->user->setFlash('donationsSubmitted',"Your Donation has been added." );
                            $this->refresh(); 
                    }
            }
            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" => "http://imsgonline.com/yiitest/images/genericbanner.jpg", "avatar" => "http://imsgonline.com/yiitest/images/genericmale.jpg", "copy" => "
Send Money
", "campaign_name" => "Joes Fundraising"), "donations" => Donations))Any idea what I'm doing wrong here??
 
     
    