?> <span class="small-px silent"><?php echo Yii::t('phrase', 'The number, street, district and village of the postal address for this business'); ?> </span> </div> </div> <div class="clearfix"> <label><?php echo $model->getAttributeLabel('office_city'); ?> <span class="required">*</span></label> <div class="desc"> <?php echo $form->dropDownList($model, 'office_city', OmmuZoneCity::getCity($model->office_province)); ?> <?php echo $form->error($model, 'office_city'); ?> <span class="small-px silent"><?php echo Yii::t('phrase', 'The city (or locality) line of the postal address for this business'); ?> </span> </div> </div> <div class="clearfix"> <label><?php echo $model->getAttributeLabel('office_province'); ?>
/** * Lists all models. */ public function actionSuggest($id = null) { if ($id == null) { if (isset($_GET['term'])) { $criteria = new CDbCriteria(); $criteria->condition = 'city LIKE :city'; $criteria->select = "city_id, city"; $criteria->order = "city_id ASC"; $criteria->params = array(':city' => '%' . strtolower($_GET['term']) . '%'); $model = OmmuZoneCity::model()->findAll($criteria); if ($model) { foreach ($model as $items) { $result[] = array('id' => $items->city_id, 'value' => $items->city); } } } echo CJSON::encode($result); Yii::app()->end(); } else { $model = OmmuZoneCity::getCity($id); $message['data'] = '<option value="">' . Yii::t('phrase', 'Select one') . '</option>'; foreach ($model as $key => $val) { $message['data'] .= '<option value="' . $key . '">' . $val . '</option>'; } echo CJSON::encode($message); } }