本文实例讲述了Yii2使用dropdownlist实现地区三级联动功能的方法。分享给大家供大家参考,具体如下:
视图部分:
rush:PHP;">
['index'],'method' => 'get','options' => ['class' => 'form-inline']
]); ?>
= $form->field($model,'cityName',['options' => ['class' => 'form-group col-lg-2']])->dropDownList(ArrayHelper::map($cities,'id','name'),['prompt' => '请选择城市'])->label('请选择城市',['class' => 'sr-only']) ?>
= $form->field($model,'areaName',['options' => ['class' => 'form-group col-lg-2']])->dropDownList(ArrayHelper::map($areas,['prompt' => '请选择区县'])->label('请选择区县','communityName',['options' => ['class' => 'form-group col-lg-2']])->dropDownList(ArrayHelper::map($communities,['prompt' => '请选择小区'])->label('请选择小区',['class' => 'sr-only']) ?>
munity" class="btn btn-info">搜索
'btn btn-primary']) ?>