Question about renderPartial in a view.

Hi again, I have been working with version 1.0.3.

If you remember, I asked you how to collect data form two or more models in a single form.

In your answer you say that I must do this:

In my controller:



<?php


public function actionCreate()


{


	$lubricentro = new Lubricentro;


	$direccion   = new Direccion;





	if(isset($_POST['Lubricentro'],$_POST['Direccion']))


	{


		$lubricentro->attributes=$_POST['Lubricentro'];


		$direccion->attributes=$_POST['Direccion'];


		$valid = $lubricentro->validate() && $direccion->validate();	


		 if ($valid) {


		 	$direccion->save();


			$lubricentro->lubricentro_id_direccion = $direccion->direccion_id;


			$lubricentro->save();


			$this->redirect(array('show','id'=>$lubricentro->lubricentro_id));					


		 }


	}


	$this->render('create',array('lubricentro'=>$lubricentro,'direccion'=>$direccion));


}


And in my view use $lubricentro and $direccion.

But with version 1.0.3 I must pass this to the _form view again:



<h2>New Lubricentro</h2>





<div class="actionBar">


[<?php echo CHtml::link('Lubricentro List',array('list')); ?>]


[<?php echo CHtml::link('Manage Lubricentro',array('admin')); ?>]


</div>





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


	'lubricentro'=>$lubricentro,'direccion'=>$direccion, // HERE I must pass the same I pass in the controller.


	'update'=>false,


)); ?>


That is no problem for me. But exist some way to not have the need to do that?

I mean a way to pass these models to the view in a manner that, if in future I add,let's say $dirección2, in the controller, I have no need to touch the 'create' view, just the '_form' view, to use it.


Another question:

I am participating in translation to spanish.

In the README I read the following:






How to Synchronize Messages


---------------------------





We have a tool to help synchronize changes made to Yii core messages


and requirement checker messages. Check out an SVN copy of Yii


framework. On command line under the "build" directory, run


the following command:





build message ../framework/messages/config.php





This will extract original messages from Yii framework and merge


them with the translations under the "messages" directory. You can


now check the merged file to see if there is any change since you


translate the messages last time. Similar procedure applies to


the requirement checker messages, which can be synchronized using


the following command:





build message ../requirements/messages/config.php





Can anybody explain me further, please not through here but with an MP.

If you want to do here is the same, I have no problem, but let's reserve this space to answers about my first question.

Nope, you have to re-declare those variables that are to be passed to _form.php.

Why don't we change the auto-generated code in the create view to this?

echo $this->renderPartial('_form', array_merge( $_data_, array('update'=>false) ) );

I ran in to the same issue and it took me an hour to figure out what was going on, but the fix is simple. Is there a reason to not do this?