当前位置: 移动技术网 > IT编程>开发语言>PHP > YII2.0之Activeform表单组件用法实例

YII2.0之Activeform表单组件用法实例

2018年04月18日  | 移动技术网IT编程  | 我要评论

本文实例讲述了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程序设计有所帮助。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网