标签:
1.controller控制中
$modelCountrytelCode = CountryTelCode::find()->orderBy(‘id DESC‘)->all(); $telCode = ArrayHelper::map($modelCountrytelCode,‘area_code‘,‘name‘); //显示name,传值area_code ***********其他代码************ return $this->render(‘createUser‘, [ ‘modelUser‘ => $modelUser, ‘modelContact‘ => $modelContact, ‘telCode‘=>$telCode ]);
2.视图文件中
<?= $form->field($modelUser,‘name‘) ?> <div class="form-group field-community-mobile required"> <label for="mobile">手机</label> <div class="input-group"> <span class="input-group-addon" style="padding: 0px;border:none;background-color: #fff;"> <?=$form->field($modelContact, ‘area_code‘) ->dropDownList($telCode,[‘prompt‘ => ‘--‘,‘style‘=>‘width:189px;padding:0px;text-align:center;‘]) ->label(false); ?> </span> <?= $form->field($modelContact,‘mobile‘)->textInput([‘style‘=>‘width:100%;‘])->label(false) ?> </div> </div>
下面两个会比较详细
其他博客关于dropdownlist链接:
1.http://blog.sina.com.cn/s/blog_88a65c1b0102ux2l.html
2.http://www.111cn.net/phper/php-mb/72865.htm
[moka同学笔记]yii2.0 dropdownlist的简单使用
标签:
原文地址:http://www.cnblogs.com/hsd1727728211/p/5857748.html