yii 二級聯動 有效 摘至
http://yxmhero1989.blog.163.com/blog/static/11215795620117199921341/
<div class="row">
<?php echo $form->labelEx($model,'province'); ?>
<?php echo $form->dropDownList($model,'province',$model->provinceList,array(
'empty'=>'-请选择-',
'ajax'=>array(
'url'=>Yii::app()->createUrl('member/dynamicCity'),
'data'=>array('pid'=>'js:this.value'),
'update'=>'#Member_city',
),
)); ?>
<?php echo $form->error($model,'province'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'city'); ?>
<?php echo $form->dropDownList($model,'city',$model->getCityList($model->province),array(
'empty'=>'-请选择-')); ?>
<?php echo $form->error($model,'city'); ?>
</div>
和 public function actionDynamicCity($pid)
{
$model = Member::model()->getCityList($pid);
foreach($model as $value=>$name)
{
echo CHtml::tag('option',array('value'=>$value),CHtml::encode($name),true);
}
}