/** * Create an instance and assign the masterId (and the actionRoute) * * @param $masterId the id of the master dropdownlist * @param mixed $actionRoute the url for the ajax data-request: used for Yii::app()->createUrl * @param array $actionParams the params for the url * @return ECascadeDropDown */ public static function master($masterId, $actionRoute = null, $actionParams = array()) { if (!isset(self::$_instance)) { self::$_instance = new ECascadeDropDown($masterId, $actionRoute, $actionParams); } else { self::$_instance->setMasterId($masterId); self::$_instance->setActionRoute($actionRoute); self::$_instance->setActionParams($actionParams); } return self::$_instance; }
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'); }
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'); ?> <?php