Using the same _form two times in view

Dear All,

I am building a website , on which user ( car owner) selects his/her permanent(Country,State,City) and present(Country,State,City) address details on one view form.

For this I wrote one form with the below code


echo $form->dropDownList($model,'country_code',CHtml::listData(MasterCountries::model()->findAll(),'country_code','country_name'))


echo $form->dropDownList($state,'state_code',CHtml::listData(MasterStates::model()->findAll('country_code=:parent_id',array(':parent_id'=>$selected_country_code)) ,'state_code','state_name'))


 echo $form->dropDownList($city,'city_code',CHtml::listData(MasterCities::model()->findAll('state_code=:parent_id',array(':parent_id'=>$selected_state_code)),'city_code','city_name'))

and trying to use the same form for permanent and for current address by just calling this twice on my view page


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

							'selected_country_code'=>$selected_country_code,

							'state'=>$state,

							'selected_state_code' =>$selected_state_code,

							'city'=>$city,

							'selected_city_code' =>$selected_city_code)

							     ); ?>

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

							'selected_country_code'=>$selected_country_code,

							'state'=>$state,

							'selected_state_code' =>$selected_state_code,

							'city'=>$city,

							'selected_city_code' =>$selected_city_code)

							     ); ?>

But this is not helping since same identifiers ( Country,State and city) are getting used in both the places .

I mean for example same identifier $country_code is being for both permanent and current address . is there any way I can use the same code again without duplicating the same code twice in the form ?

Thanks for your help

Regards

Kiran

If you pass in a key and use that to use the CActiveForm to produce tabular elements that should solve you’re issue. Tabular inputs are covered here:

http://www.yiiframework.com/doc/guide/1.1/en/form.table

Thank You :rolleyes: