Example #1
0
 public function actionGetArea()
 {
     $list = array();
     $init = $arealevel = '0';
     $pid = Yii::app()->request->getParam('pid');
     $list = area::model()->getlist();
     $arrPid = explode(',', $pid);
     $level = Yii::app()->request->getParam('level');
     $arealevel = $level + 1;
     $data = array('list' => $list, 'arrPid' => $arrPid, 'arealevel' => $arealevel);
     if (Yii::app()->request->isAjaxRequest) {
         $this->renderPartial('area', $data, '', TRUE, TRUE);
     } else {
         $this->render('area', $data);
     }
 }
Example #2
0
            <?php 
$state_data = Area::model()->findAll("grade=:grade", array(":grade" => 1));
$state = CHtml::listData($state_data, "id", "name");
$s_default = $model->isNewRecord ? '' : $model->state;
echo '省&nbsp;' . CHtml::dropDownList('AddressResult[state]', $s_default, $state, array('empty' => '请选择省份', 'ajax' => array('type' => 'GET', 'url' => CController::createUrl('dynamiccities'), 'update' => '#AddressResult_city', 'data' => 'js:"AddressResult_state="+jQuery(this).val()')));
//empty since it will be filled by the other dropdown
$c_default = $model->isNewRecord ? '' : $model->city;
if (!$model->isNewRecord) {
    $city_data = area::model()->findAll("parent_id=:parent_id", array(":parent_id" => $model->state));
    $city = CHtml::listData($city_data, "id", "name");
}
$city_update = $model->isNewRecord ? array() : $city;
echo '&nbsp;市&nbsp;' . CHtml::dropDownList('AddressResult[city]', $c_default, $city_update, array('empty' => '请选择城市', 'ajax' => array('type' => 'GET', 'url' => CController::createUrl('dynamicdistrict'), 'update' => '#AddressResult_district', 'data' => 'js:"AddressResult_city="+jQuery(this).val()')));
$d_default = $model->isNewRecord ? '' : $model->district;
if (!$model->isNewRecord) {
    $district_data = area::model()->findAll("parent_id=:parent_id", array(":parent_id" => $model->city));
    $district = CHtml::listData($district_data, "id", "name");
}
$district_update = $model->isNewRecord ? array() : $district;
echo '&nbsp;区&nbsp;' . CHtml::dropDownList('AddressResult[district]', $d_default, $district_update, array('empty' => '请选择地区'));
?>
                
                <?php 
echo '&nbsp;邮编:' . $form->textField($model, 'zipcode', array('size' => 10, 'maxlength' => 45));
?>
                <?php 
echo $form->error($model, 'zipcode');
?>
            </div>

	<div class="row">