yii2.0 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']) ?>
//查库循环下拉列表
<?= $form->field($model, 'adsite_id')->dropDownList(ArrayHelper::map(adsite::find()->all(),'adsite_id','adsie_name') ,['prompt' => '请选择父级分类']) ?>
展示页面根据id显示名称
[
'attribute' => 'parent_id',
'value' => function ($model) {
$parent_id=$model->parent_id;
if($parent_id==0){
return $model->cat_name;
}
$query = new \yii\db\Query();
$query->select('*')
->from('ecs_category')
->where(['cat_id'=>$parent_id]);
$command = $query->createCommand();
$res=$command->queryOne();
return $name=$res['cat_name'];
},
'format' => 'raw',
],
<? 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]) ?>
//隐藏label
<?= $form->field($model, 'com_id')->textInput()->hiddenInput(['value'=>'com_id'])->label(false); ?>
<? echo Html::submitButton('提交', ['class'=>'btn btn-primary','name' =>'submit-button']) ?>
<? echo Html::resetButton('重置', ['class'=>'btn btn-primary','name' =>'submit-button']) ?>
<?php ActiveForm::end(); ?>
yii2.0 Activeform表单部分组件使用方法的更多相关文章
- yii2.0 Activeform表单部分组件使用方法 [ 2.0 版本 ]
文本框:textInput(); 密码框:passwordInput(); 单选框:radio(),radioList(); 复选框:checkbox(),checkboxList(); 下拉框:dr ...
- [YII2] Activeform表单部分组件使用方法
文本框:textInput(); 密码框:passwordInput(); 单选框:radio(),radioList(); 复选框:checkbox(),checkboxList(); 下拉框:dr ...
- YII2.0 Activeform表单组件的使用方法
Activeform文本框:textInput();密码框:passwordInput();单选框:radio(),radioList();复选框:checkbox(),checkboxList(); ...
- yii2之ActiveForm表单使用
因目前项目并非前后端分离模式,且用到PHP的yii2框架(所有html代码,js较多内嵌在.php文件内多少采用同步提交[喷墨中...]),遂对于前端面上需要用到的yii2小组件一些整理(因是前端若涉 ...
- yii2 创建ActiveForm(表单)
表单的生成表单中的方法 ActiveForm::begin()方法 ActiveForm::end()方法 getClientOptions()方法 其它方法:errorSum ...
- YII2.0 验证表单
控制器代码 <?php namespace app\modules\pub\controllers; use Yii; use backend\base\BaseController; use ...
- yii2接收activeform表单信息
第一种方法: $model->load(Yii::$app->request->post()); 第二种方法: 获取具体的某一项的值 $demo = $_POST['模型名']['字 ...
- form-create 3.0 版本发布,好用的Vue3版本动态表单生成组件
form-create 是一个可以通过 JSON 生成具有动态渲染.数据收集.验证和提交功能的表单生成组件.支持2个UI框架,并且支持生成任何 Vue 组件.内置20种常用表单组件和自定义组件,再复杂 ...
- yii中调整ActiveForm表单样式
Yii2中对于表单和字段的支持组件为ActiveForm和ActiveField, <?php $form = ActiveForm::begin([ 'id' => 'login-for ...
随机推荐
- 23-React Render Element
第23节 React Render Element 1.Element 元素是反应应用程序的最小积木. 元素描述你在屏幕上看到的内容.: const element= <h1>你好,世界& ...
- ooize的使用01
1.常用的调度框架 1.1 linux crontab 1.1.1 编写一个crontab,每一分钟向/opt/data/cronlogs文件中添加当前时间 crontab -e
- Best 3D Modeling software under Ubuntu
Blender Blender is the best free and open source 3D modelling program out there by a long shot! The ...
- socket了解(转)
http://blog.chinaunix.net/uid-26000296-id-3758651.html http://blog.csdn.net/mengyafei43/article/deta ...
- 18TH赛事管理
赛事管理者 项目psp: 一.计划 估计这个任务需要7天时间 二.开发 1.需求分析 作为一个赛事管理者,我希望知道每场比赛的队伍得分和积分情况,以便给每队进行排名. 2.生成设计文档 查询出每场得分 ...
- POJ Challenge消失之物
Description ftiasch 有 N 个物品, 体积分别是 W1, W2, ..., WN. 由于她的疏忽, 第 i 个物品丢失了. "要使用剩下的 N - 1 物品装满容积为 x ...
- PHP表单header post get
header 是服务器以HTTP协议到浏览器前所送出的字符串 在表头与HTML文件之间需要空出一行 $_POST $_GET 必须要有method="post" 上传文件类表单 ...
- RDLC隔行变色的实现
在RDLC设计页面设置行属性中的Background为: =IIF((RowNumber(Nothing)) Mod 2 =1,"Transparent","#F6FAF ...
- Window通过cmd查看端口占用、相应进程、杀死进程
在windows下启动程序时候经常出现端口占用, 修改本程序端口是一种解决思路,但是更多时候希望直接杀掉占用端口的程序: 一. 查看所有进程占用的端口 在开始-运行-cmd,输入: netsta ...
- hihoCoder挑战赛25
萌新第一次打hihoCoder的比赛有点慌 T1 T1并不是特别难想到dp就好做了 显而易见的是一个01背包问题 Code: #include <cstdio> #include < ...