public function actionCitydata() { //check if isAjaxRequest and the needed GET params are set ECascadeDropDown::checkValidRequest(); //load the cities for the current province id (=ECascadeDropDown::submittedKeyValue()) $data = Imirenge::model()->findAll('iddistrict=:iddistrict', array(':iddistrict' => ECascadeDropDown::submittedKeyValue())); //Convert the data by using //CHtml::listData, prepare the JSON-Response and Yii::app()->end ECascadeDropDown::renderListData($data, 'id', 'umurenge'); }
<div class="row"> <?php echo $form->label($model, 'iddistrict'); ?> <?php echo $form->textField($model, 'iddistrict'); ?> </div> <div class="row"> <?php echo $form->label($model, 'idumurenge'); ?> <?php echo $form->dropDownList($model, 'idumurenge', GxHtml::listDataEx(Imirenge::model()->findAllAttributes(null, true)), array('prompt' => Yii::t('app', 'All'))); ?> </div> <div class="row"> <?php echo $form->label($model, 'akagali'); ?> <?php echo $form->textField($model, 'akagali', array('maxlength' => 20)); ?> </div> <div class="row"> <?php echo $form->label($model, 'umudugudu'); ?>
<?php $uturere = CHtml::listData(IguDistrict::model()->findAll(array('order' => 'district')), 'id', 'district'); echo CHtml::activeDropDownList($model, 'iddistrict', $uturere, array('id' => 'id_district', 'prompt' => 'Hitamo Akarere')); ?> <?php echo $form->error($model, 'iddistrict'); ?> </div><!-- row --> </td> <td> <div class="row"> <?php echo $form->labelEx($model, 'idumurenge'); ?> <?php $imirenge = CHtml::listData(Imirenge::model()->findAll('iddistrict=:iddistrict', array(':iddistrict' => $model->iddistrict)), 'id', 'umurenge'); echo CHtml::activeDropDownList($model, 'idumurenge', $imirenge, array('id' => 'id_umurenge', 'prompt' => 'Hitamo Umurenge')); ECascadeDropDown::master('id_district')->setDependent('id_umurenge', array('dependentLoadingLabel' => 'Loading Imirenge ...'), 'site/citydata'); ?> <?php echo $form->error($model, 'idumurenge'); ?> </div><!-- row --> </td> </tr> <tr> <td> <div class="row"> <?php echo $form->labelEx($model, 'akagali');