Yii2原生SQL+GridView分页问题
http://www.yiichina.com/question/235
Yii2 GridView与dropdownList结合的用法
http://www.yiichina.com/tutorial/473
<?=$form->field($model, ‘provinces‘)->dropDownList(ArrayHelper::map(common\models\GlobalRegion::find()->where([‘region_type‘=>1])->asArray()->all(),‘region_id‘,‘region_name‘), [ ‘style‘=>‘width:150px‘, ‘prompt‘=>‘请选择省‘, ‘onchange‘=>‘ $.post("index.php?r=user/lists&id=‘.‘"+$(this).val(),function(data){ $("#user-citys").html("<option value= >请选择市</option>");$("#user-countrys").html("<option value= >请选择县</option>"); $("#user-citys").append(data); });‘, ]); ?>
<?=$form->field($model, ‘citys‘)->dropDownList(ArrayHelper::map([],‘region_id‘,‘region_name‘), [ ‘style‘=>‘width:150px‘, ‘prompt‘=>‘请选择市‘, ‘onchange‘=>‘ $.post("index.php?r=user/lists&id=‘.‘"+$(this).val(),function(data){ $("#user-countrys").html("<option value=>请选择县</option>"); $("#user-countrys").append(data); });‘, ]); ?>
<?=$form->field($model, ‘countrys‘)->dropDownList(ArrayHelper::map([],‘region_id‘,‘region_name‘), [ ‘style‘=>‘width:150px‘, ‘prompt‘=>‘请选择县‘, ‘onchange‘=>‘ $.post("index.php?r=branches/lists&id=‘.‘"+$(this).val(),function(data){ });‘, ]); ?>
public function actionLists(){
//查出底下的内容
$regionmodel=GlobalRegion::find()->where([‘parent_id‘=>$_GET[‘id‘]])->asarray()->all(); foreach($regionmodel as $v){ $str="<option value=".$v[‘region_id‘].">".$v[‘region_name‘]."</option>"; echo $str; } }