本文实例讲述了yii2.0之activeform表单组件用法。分享给大家供大家参考,具体如下:
activeform
文本框:textinput();
密码框:passwordinput();
单选框:radio(),radiolist();
复选框:checkbox(),checkboxlist();
下拉框:dropdownlist();
隐藏域:hiddeninput();
文本域:textarea(['rows'=>3]);
文件上传:fileinput();
提交按钮:submitbutton();
重置按钮:resetbuttun();
<?php
$form = activeform::begin([
'action' => ['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']) ?>
<?php activeform::end(); ?>
希望本文所述对大家基于yii框架的php程序设计有所帮助。
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!