使用过yii框架的同学都知道,yii框架中的form表单可以使用yii内部定义form组件来进行提交,小编今天就带着大家来看看,yii中的form表单组件吧!
话不多说上代码:
$form = ActiveForm::begin([
'action' => ['test/getpost'],
'method'=>'post',
]); ?>
=Html::beginForm('','post',['id'=>'form','class'=>'form','data'=>'myself']);?>
=Html::input('text','test','',['class'=>'form-control','placeholder'=>'hehe'])->hint('Please enter your test')->label('Name');?>
=Html::input('email','email','admin@admin.com',['class'=>'form-control']);?>
=Html::input('password','pwd','',['class'=>'form-control']);?>
'form-control']);?>
=Html::textInput('test','hehe',['class'=>'form-control']);?>
=Html::textInput('email','admin@admin.com',['class'=>'form-control']);?>
'form-control']);?>
'form-control']);?>
=Html::textarea('area','',['class'=>'form-control','row'=>'3']);?>
=Html::radio('sex',true,['class'=>'form-control']);?>
=Html::radioList('height','1',['1'=>'160','2'=>'170','3'=>'180'],['class'=>'form-control']);?>
=Html::checkbox('haha',true,['class'=>'form-control']);?>
=Html::checkboxList('xixi','1',['1'=>'160','2'=>'170','3'=>'180'],['class'=>'form-control']);?>
=Html::dropDownList('list','2',['1'=>'160','2'=>'170','3'=>'180'],['class'=>'form-control'])?>
=Html::label('显示的','test',['style'=>'color:#ff0000']);?>
=Html::fileInput('img',null,['class'=>'btn btn-default']);?>
=Html::button('普通按钮',['class'=>'btn btn-primary']);?>
=Html::submitButton('提交按钮',['class'=>'btn btn-primary']);?>
=Html::resetButton('重置按钮',['class'=>'btn btn-primary']);?>
=Html::endForm()?>文本框:textInput();
密码框:passwordInput();
单选框:radio(),radioList();
复选框:checkbox(),checkboxList();
下拉框:dropDownList();
隐藏域:hiddenInput();
文本域:textarea([‘rows’=>3]);
文件上传:fileInput();
提交按钮:submitButton();
重置按钮:resetButtun();
以下是代码示例:
['test/getpost'],'method'=>'post',]); ?>
echo $form->field($model, 'username')->textInput(['maxlength' => 20]) ?>
echo $form->field($model, 'password')->passwordInput(['maxlength' => 20]) ?>
echo $form->field($model, 'sex')->radioList(['1'=>'男','0'=>'女']) ?>
echo $form->field($model, 'edu')->dropDownList(['1'=>'大学','2'=>'高中','3'=>'初中'], ['prompt'=>'请选择','style'=>'width:120px']) ?>
echo $form->field($model, 'file')->fileInput() ?>
echo $form->field($model, 'hobby')->checkboxList(['0'=>'篮球','1'=>'足球','2'=>'羽毛球','3'=>'乒乓球']) ?>
echo $form->field($model, 'info')->textarea(['rows'=>3]) ?>
echo $form->field($model, 'userid')->hiddenInput(['value'=>3]) ?>
echo Html::submitButton('提交', ['class'=>'btn btn-primary','name' =>'submit-button']) ?>
echo Html::resetButton('重置', ['class'=>'btn btn-primary','name' =>'submit-button']) ?>
以上就是本章所有内容,希望会给大家带来帮助。
相关推荐:
UQCMS云商是一款B2B2C电子商务软件 ,非常适合初创的创业者,个人及中小型企业。程序采用PHP+MYSQL,模板采用smarty模板,二次开发,简单方便,无需学习其他框架就可以自行模板设计。永久免费使用,操作简单,安全稳定。支持PC+WAP+微信三种浏览方式,支持微信公众号。









