Send var to view

Hi, i’m trying to send one var to my render




$model=new Usuario;

		$groups=new CActiveDataProvider('Grupo');


		// Uncomment the following line if AJAX validation is needed

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


		if(isset($_POST['Usuario']))

		{

			$model->attributes=$_POST['Usuario'];

			$validation = $this->performAjaxValidation($model);

			$isValid = $this->isValid($validation);

			if(!$isValid){echo $validation; exit();}

			if($model->save()){

				if(!isset($_POST["ajax"])){

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

				}

				else echo('{"saved": "1", "message": "Saved with success"}');


			}

			else echo('{"saved": "0", "message": "Not saved"}');	

		}

		else{

			if(isset($_POST)){

	   			$this->renderPartial('create',array(

					'model'=>$model,

					'groups'=>$groups

					));

			}

			else {	

				$this->render('create',array(

					'model'=>$model,

					'groups'=>$groups

					));

				}

		}



As you can see i;m sending the groups.

BUT, when i try to do a var_dump on the other side i receive one error.

If i do the vardump with the new CActiveDataProvider(‘Grupo’) its ok… how i can send the var?

Can you paste the error you have?

Error

PHP Error [8]

Undefined variable: groups (/Developer/php/MonitorSVN/protected/views/usuario/_form.php:65)

In the code above you are rendering the "create" view… but the error happens in the "_form" view…

are you sending the variable $groups from the "create" view to the "_form" view ?

How i can do that?

Just check the content of the view "create" you will see there the renderpartial…

In create view you should have something like:




<?php echo $this->renderPartial('_form', array('model'=>$model, 'groups'=>$groups)); ?>