<?php
//引入命名空間
use yii\helpers\Html;
?>
<?php //表單:Html::beginForm(提交地址,提交方法,屬性數組);?>php
$form = ActiveForm::begin([ 'action' => ['test/getpost'], 'method'=>'post', ]);
<?=Html::beginForm('','post',['id'=>'form','class'=>'form','data'=>'myself']);?>
<?php //(二)輸入框:Html::input(類型,name值,默認值,屬性數組;)?>
<?=Html::input('text','test','',['class'=>'form-control','placeholder'=>'hehe']);?>
<?=Html::input('email','email','admin@admin.com',['class'=>'form-control']);?>
<?=Html::input('password','pwd','',['class'=>'form-control']);?>
<?Html::input('hidden','hidden','',['class'=>'form-control']);?>
<hr/>
<?php //Html::表單類型input(name值,默認值,屬性數值);?>
<?=Html::textInput('test','hehe',['class'=>'form-control']);?>
<?=Html::textInput('email','admin@admin.com',['class'=>'form-control']);?>
<?Html::passwordInput('pwd','',['class'=>'form-control']);?>
<?Html::hiddenInput('hidden','',['class'=>'form-control']);?>
<hr/>
<?php //(三) 文本域 Html::textarea()?>
<?=Html::textarea('area','',['class'=>'form-control','row'=>'3']);?>
<hr/>
<?php //單選按鈕 Html::checkbox(name值,是否選中,屬性數組)?>
<?=Html::radio('sex',true,['class'=>'form-control']);?>
<?=Html::radioList('height','1',['1'=>'160','2'=>'170','3'=>'180'],['class'=>'form-control']);?>
<?php //複選框?>
<?=Html::checkbox('haha',true,['class'=>'form-control']);?>
<?php //複選框列表?>
<?=Html::checkboxList('xixi','1',['1'=>'160','2'=>'170','3'=>'180'],['class'=>'form-control']);?>
<?php //下拉列表?>
<?=Html::dropDownList('list','2',['1'=>'160','2'=>'170','3'=>'180'],['class'=>'form-control'])?>
<?=Html::label('顯示的','test',['style'=>'color:#ff0000']);?>
<hr/>
<?php //上傳控件?>
<?=Html::fileInput('img',null,['class'=>'btn btn-default']);?>
<hr/>
<?php //按鈕?>
<?=Html::button('普通按鈕',['class'=>'btn btn-primary']);?>
<?=Html::submitButton('提交按鈕',['class'=>'btn btn-primary']);?>
<?=Html::resetButton('重置按鈕',['class'=>'btn btn-primary']);?>
<?=Html::endForm()?>
數組