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 ...
随机推荐
- Centos7安装图形界面
安装好字符操作系统后,使用网络安装(网络安装比较简单,不需要配置yum文件): yum groupinstall "GNOME Desktop" -y startx centos7 ...
- xib的UIScrollView自适应高度
1.首先,我们先把这个size classes关了(需要使用的童鞋无视掉,也无视掉我的工程名,这是我弄高德地图创建的工程) 2.添加一个scrollview上去,设置上下左右约束为0 3.然后搞一个v ...
- 关于editor网页编辑器ueditor.config.js 配置图片上传
最近公司项目在做一个门户网站,其中新闻和简介等部分使用到了ueditor编辑器,但是上级明确指示需要图片上传这个功能,这时却发现图片上传功能不能正常使用,上传时一直报错,网上收了好几个处理办法,都说的 ...
- UVALive 3902 网络
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- 微信小程序-基础内容组件
icon 图标 示例: <view class="group"> <block wx:for="{{iconSize}}"> <i ...
- 在 ASP.NET MVC 中使用 HTML Helpers 的那些事
在 ASP.NET MVC 中使用 HTML Helpers 方法,可以返回得到标准的 HTML 标签,就像 <input>.<button> 或者 <img> 等 ...
- JFinal 国际化
要支持国际化,需要在容器初始化的时候配置一个处理国际化的全局拦截器.比如可以使用 com.jfinal.i18n.I18nInterceptor 配置拦截器: public class MppConf ...
- ajax局部刷新
//5秒刷新一次 $(function () { setInterval(Refresh, 5000); }); //ajax局部刷新 function Refresh() { $.ajax({ ty ...
- 1006. Sign In and Sign Out (25)
At the beginning of every day, the first person who signs in the computer room will unlock the door, ...
- Pod 的安装
1.如果之前已经安装过的 gem list --local | grep cocoapods 会看到如下输出: cocoapods (1.1.1)cocoapods-deintegrate (1.0. ...