文本框: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表单部分组件使用方法的更多相关文章

  1. yii2.0 Activeform表单部分组件使用方法 [ 2.0 版本 ]

    文本框:textInput(); 密码框:passwordInput(); 单选框:radio(),radioList(); 复选框:checkbox(),checkboxList(); 下拉框:dr ...

  2. [YII2] Activeform表单部分组件使用方法

    文本框:textInput(); 密码框:passwordInput(); 单选框:radio(),radioList(); 复选框:checkbox(),checkboxList(); 下拉框:dr ...

  3. YII2.0 Activeform表单组件的使用方法

    Activeform文本框:textInput();密码框:passwordInput();单选框:radio(),radioList();复选框:checkbox(),checkboxList(); ...

  4. yii2之ActiveForm表单使用

    因目前项目并非前后端分离模式,且用到PHP的yii2框架(所有html代码,js较多内嵌在.php文件内多少采用同步提交[喷墨中...]),遂对于前端面上需要用到的yii2小组件一些整理(因是前端若涉 ...

  5. yii2 创建ActiveForm(表单)

    表单的生成表单中的方法    ActiveForm::begin()方法    ActiveForm::end()方法    getClientOptions()方法    其它方法:errorSum ...

  6. YII2.0 验证表单

    控制器代码 <?php namespace app\modules\pub\controllers; use Yii; use backend\base\BaseController; use ...

  7. yii2接收activeform表单信息

    第一种方法: $model->load(Yii::$app->request->post()); 第二种方法: 获取具体的某一项的值 $demo = $_POST['模型名']['字 ...

  8. form-create 3.0 版本发布,好用的Vue3版本动态表单生成组件

    form-create 是一个可以通过 JSON 生成具有动态渲染.数据收集.验证和提交功能的表单生成组件.支持2个UI框架,并且支持生成任何 Vue 组件.内置20种常用表单组件和自定义组件,再复杂 ...

  9. yii中调整ActiveForm表单样式

    Yii2中对于表单和字段的支持组件为ActiveForm和ActiveField, <?php $form = ActiveForm::begin([ 'id' => 'login-for ...

随机推荐

  1. C++多线程の线程通信future,promise,async

  2. 利用wangEditor获取文章格式和内容

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs& ...

  3. 关于phpcms 万一忘记密码怎么破?

    莫慌~海洋小生教你~我也是偷偷学来的,呀哈哈哈! first:............................你就认命吧!哈哈哈... 开玩笑开玩笑! LOOK HERE ↓: 1.在没有安装 ...

  4. Cocos2d-x 核心概念 - 导演(Director)

    导演类(Director) 用于管理场景对象,采用的是单例模式(单例模式能保存一致的配置信息,方便管理场景对象) 获得导演实例的语句如下 local director = cc.Director:ge ...

  5. 如何为数据源向导填加一种自定义的数据源类型(win示例)

    https://www.devexpress.com/Support/Center/Example/Details/T310160

  6. CSS 如何使DIV层水平居中

    今天用CSS碰到个很棘手的问题,DIV本身没有定义自己居中的属性, 网上很多的方法都是介绍用上级的text-align: center然后嵌套一层DIV来解决问题. 可是事实上这样的方法科学吗? 经过 ...

  7. Javascript 数组常用操作方法

    一.数组 Array 1.创建数组 /* 构造函数 */ var arr1 = new Array(); //创建一个空数组 var arr1 = new Array(5); //创建指定长度数组(数 ...

  8. sqllite 入门

    链接: http://www.jb51.net/article/52064.htm

  9. 慕课网__CSS_网页图标制作

    参考地址:http://www.flowerboys.cn/font/article/fontsArticle/how-to-turn-your-icons-into-a-web-font.html

  10. java中的数据结构(集合|容器)

    对java中的数据结构做一个小小的个人总结,虽然还没有到研究透彻jdk源码的地步.首先.java中为何需要集合的出现?什么需求导致.我想对于面向对象来说,对象适用于描述任何事物,所以为了方便对于对象的 ...