Hi,
I'm new to yii.
I have to create a suite of dependet dropdownlist, but i need your help.
This is my code in the _form.php
and this in the controller
I have copied it from the tutorial but it won't work.
Anyone can help me please?
Thank you
I'm new to yii.
I have to create a suite of dependet dropdownlist, but i need your help.
This is my code in the _form.php
<div class="row"> <?php echo $form->labelEx($model,'mut_immobile_prov_sigla'); ?> <?php echo $form->dropDownList($model,'mut_immobile_prov_sigla', CHtml::listData(TabProvince::model()->findAll(), 'prov_sigla','prov_descr'), array('empty'=>'', 'ajax' => array( 'type'=>'POST', //request type 'url'=>CController::createUrl('DataMutuiController/dynamiccities'), //url to call. //Style: CController::createUrl('currentController/methodToCall') 'update'=>'#mut_immobile_com_id', //selector to update //'data'=>'js:javascript statement' //leave out the data key to pass all form values through ) )); ?> <?php echo $form->error($model,'mut_immobile_prov_sigla'); ?> </div> <div class="row"> <?php echo $form->labelEx($model,'mut_immobile_com_id'); ?> <?php echo $form->dropDownList($model,'mut_immobile_com_id', array(), array('empty'=>'')); ?> <?php echo $form->error($model,'mut_immobile_com_id'); ?> </div>
and this in the controller
public function actionDynamiccities() { $data=Location::model()->findAll('parent_id=:parent_id', array(':parent_id'=>(string) $_POST['mut_immobile_prov_sigla'])); $data = CHtml::listData(TabComuni::model()->findAll(), 'com_id','com_descr'); foreach($data as $value=>$name) { echo CHtml::tag('option', array('value'=>$value),CHtml::encode($name),true); } }
I have copied it from the tutorial but it won't work.
Anyone can help me please?
Thank you
