<?= $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;">
<?=$form->field($modelContact, 'area_code')->dropDownList($telCode,['prompt' => '+86'])->label(false); ?>
</span>
<?= $form->field($modelContact,'mobile',['labelOptions' => ['class' => 'form-control']])->label(false) ?>
</div>
</div>
<div class="form-group field-community-mobile required">
<label for="mobile">手机
</label>
<div class="input-group">
<span class="input-group-addon" style="padding: 0px;">
<select style="padding:7px 0; " name="area_code">
<option>1454</option>
<option>32</option>
<option>453</option>
<option>12</option>
</select>
</span>
<input type="text" name="" class="form-control" value=""/>
</div>
</div>
下面内容来自于网络
http://www.cnblogs.com/benlightning/p/4536392.html
<?php $form = ActiveForm::begin([
'options'=>['enctype'=>'multipart/form-data','class' => 'form-horizontal'],
'fieldConfig' => [ //统一修改字段的模板
'template' => "{label}\n<div class=\"col-lg-5\">{input}</div>\n<div class=\"col-lg-3\">{error}</div>",
//修改显示内容默认为{label}\n{input}\n{hint}\n{error} \n是html代码显示时的换行
'labelOptions' => ['class' => 'col-lg-2 control-label'], //修改label的样式
],
]); ?>
Image(16)
//修改某字段的样式
<?= $form->field($model, 'img_path',[
'template' => "{label}\n<div class=\"col-lg-3\">{input}</div>\n<div class=\"col-lg-2\"><label for=\"uploadImg\" class=\"btn btn-default forfocus1\" onclick=\"changeImg(1,'forfocus');\">选择图片<img src=\"\"></label></div>\n{error}",
'labelOptions' => ['class' => 'col-lg-2 control-label'],
])->textInput(['maxlength' => 255,'placeholder'=>'专题图片','readonly'=>true])->label('专题名称')->hint('错误提示信息') ?>
以下为一个完整的例子
<?php $form = ActiveForm::begin([
'options'=>['enctype'=>'multipart/form-data','class' => 'form-horizontal'],
'fieldConfig' => [
'template' => "{label}\n<div class=\"col-lg-5\">{input}</div>\n<div class=\"col-lg-5\">{error}</div>",
'labelOptions' => ['class' => 'col-lg-2 control-label'],
],
]); ?>
<?= $form->field($model, 'title')->textInput(['maxlength' => 255,'placeholder'=>'请输入专题名称'])->label('专题名称') ?>
<?= $form->field($model, 'img_path',[
'template' => "{label}\n<div class=\"col-lg-3\">{input}</div>\n<div class=\"col-lg-2\">
<label for=\"uploadImg\" class=\"btn btn-default forfocus1\" onclick=\"changeImg(1,'forfocus');\">选择图片
<img src=\"\"></label></div>\n{error}",
'labelOptions' => ['class' => 'col-lg-2 control-label'],
])->textInput(['id'=>'img_path','maxlength' => 255,'placeholder'=>'专题图片','readonly'=>true])->label('专题名称') ?>
<?= $form->field($model, 'showImg',[
'template' => "{label}\n<div id=\"showImg\" class='col-lg-10'></div>",
'labelOptions' => ['class' => 'col-lg-2 control-label'],
])->label('图片预览') ?>
<?= $form->field($model, 'link_to')->textInput(['maxlength' => 255,'placeholder'=>'请输入专题链接'])->label('专题链接') ?>
</div>
<div class="form-group" style="margin-left: 50px;">
<?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>