/**
  * Lists all models.
  */
 public function actionSuggest($id = null)
 {
     if ($id == null) {
         if (isset($_GET['term'])) {
             $criteria = new CDbCriteria();
             $criteria->condition = 'country LIKE :country';
             $criteria->select = "country_id, country";
             $criteria->order = "country_id ASC";
             $criteria->params = array(':country' => '%' . strtolower($_GET['term']) . '%');
             $model = OmmuZoneCountry::model()->findAll($criteria);
             if ($model) {
                 foreach ($model as $items) {
                     $result[] = array('id' => $items->country_id, 'value' => $items->country);
                 }
             }
         }
         echo CJSON::encode($result);
         Yii::app()->end();
     } else {
         $model = OmmuZoneCountry::getCountry();
         $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);
     }
 }
Пример #2
0
		<div id="ajax-message">
			<?php 
echo $form->errorSummary($model);
?>
		</div>
		<?php 
//begin.Messages
?>

		<div class="clearfix">
			<?php 
echo $form->labelEx($model, 'country_id');
?>
			<div class="desc">
				<?php 
echo $form->dropDownList($model, 'country_id', OmmuZoneCountry::getCountry());
?>
				<?php 
echo $form->error($model, 'country_id');
?>
				<?php 
/*<div class="small-px silent"></div>*/
?>
			</div>
		</div>

		<div class="clearfix">
			<?php 
echo $form->labelEx($model, 'province');
?>
			<div class="desc">