<?php
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
?>
<?php $form= ActiveForm::begin([
'id'=>'register',
'layout'=>'horizontal',
'action'=>'req.php',
'method'=>'get',
'fieldConfig' => [
'template' => "{label}\n<div class=\"col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>",
'labelOptions' => ['class' => 'col-lg-1 control-label'],
]
]) ?>
<!--文本框-->
<?php echo $form->field($model, 'name')->textInput(['placeholder'=>'请输入用户名'])?>
<!--密码框-->
<?php echo $form->field($model, 'password')->passwordInput()?>
<!--多选框(单个)-->
<?php /*echo $form->field($model, 'hobby')->checkbox(['label'=>'爱好','uncheck'=>null,'value'=>1])*/?>
<!--多选框(多个)默认多选框是纵向排列 使用->inline()横向排列-->
<?php echo $form->field($model, 'hobby')->inline()->checkboxList(['1'=>'篮球','2'=>'排球'])?>
<!--多选框(多个)template设置模板,separator设置分割符 -->
<?php echo $form->field($model,'hobby')->inline()->checkboxList(['1'=>'篮球','2'=>'排球'])?>
<!--下拉框-->
<?php echo $form->field($model, 'city')->dropDownList(['1'=>'北京','2'=>'上海'],['prompt'=>'请选择','width'=>'120'])?>
<!--文件上传-->
<?php echo $form->field($model,'file')->fileInput()?>
<!--隐藏域-->
<?php echo $form->field($model,'token')->hiddenInput(['value'=>'1234567890'])->label(false);?>
<!--listbox-->
<?php echo $form->field($model,'city')->listBox(['1'=>'北京','2'=>'上海'],['prompt'=>'请选择'])?>
<!--单选按钮 多个-->
<?php echo $form->field($model,'gender')->inline()->radioList([1=>'男','2'=>'女'])?>
<!--单选按钮 一个-->
<?php echo $form->field($model,'gender')->radioList(['2'=>'选中'])?>
<!--提交按钮-->
<?php echo Html::submitButton('注册',['class' => 'btn btn-primary', 'name' => 'login-button'])?>
<?php ActiveForm::end();?>