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 ...
随机推荐
- linux开启telnet
windows客户端如果通过cmd窗口连接到远程linux服务器,可以使用telnet: centos系统默认telnet 23端口是关闭的. 服务器本地使用nmap ip地址 -p 23 查看tel ...
- Excel的数据导入到PB的DW中
Excel的数据导入到PB的DW中//==================================================================== // Event:cb_ ...
- FMDB
一.FMDB简介 1.FMDB简介 iOS中原生的SQLite API在进行数据存储的时候,需要使用C语言中的函数,操作比较繁琐.于是,就出现了一系列将SQLite API进行封装的库,例如FMDB. ...
- WebForm 控件
一.简单控件 1.Label(作用:显示文字) Web中: <asp:Label ID="Label1" runat="server" Text=&quo ...
- 纯硬盘安装Kali 无需U盘
工具: EasyBCD 安装后启动,然后依次点击 添加新条目 >> NeoGrub >> 安装 然后如下图 点击配置,然后弹出一个记事本窗口,先最小化.进行如下操作: 1.拷贝 ...
- HashMap原理与优化
参考文献: HashMap的工作原理 java中HashMap重要性质和优化总结 一.HashMap的基本了解 基本定义:根据源代码的描述可知,HashMap是基于哈希表的Map接口的实现,其包含了M ...
- centos7 docker redis
docker run --name=redistmp -ti centos /bin/bash yum -y install gcc tcl make cd /home wget http://dow ...
- json.stringfy()和json.parse()
json.stringfy()将对象.数组转换成字符串:json.parse()将字符串转成json对象. json.stringfy(): 语法: JSON.stringify(value [, ...
- MemCache缓存multiget hole详解
multiget 是什么 multiget 指的是从 memcache(或其他分布式缓存) 一次性获得多个键值,一般由 memcached client 自行实现. multiget hole是什么 ...
- shell下>和>>的区别
> :如果文件不存在,同上,如果文件存在,先将文件清空,然后将数据填入此文件 >> :如果文件不存在,将创建新的文件,并将数据送至此文件:如果文件存在,则将数据添加在文件后面