yii  的dropdownlist,用yii的session可以记下选中的状态

      $form = $this->beginWidget('CActiveForm',array('action'=>$this->CreateUrl('exchange/search')));
?>
<div id='add'><span style='font-size:1.2em;margin-right:10px;'>类型:</span>
<?php
$check=Yii::app()->session['check'];
// echo $check;die;
echo $form->dropDownList($loginForm,'check',array('0'=>'未通过','1'=>'通过','2'=>'拒绝'),
array('style'=>'margin-right:30px;width:100px;height:30px','placeholder'=>'用户id',
'options'=>array($check=>array('selected'=>true))))?> <input type='submit' name='search' value='查询' class='btn btn-success'>
</div>
<?php
$this->endWidget();

  

yii表单2

<?php $form=$this->beginWidget('CActiveForm')?>
<table style="width:540px;margin-top:1%;">
<tr style="text-align:center; background-color:#198ef0;color:white;">
<td style="font-size:1.3em;height:30px;">添加</td>
</tr> <tr>
<td><span style="display:inline-block;width:100px;text-align:left;font-size:1.2em;padding-top:5px;padding-bottom:5px;">用户名: </span><?php echo $form->textField($user,'username')?></td>
</tr>
<tr>
<td><span style="display:inline-block;width:100px;text-align:left;font-size:1.2em;padding-top:5px;padding-bottom:5px;">邮箱: </span><?php echo $form->textField($user,'email')?></td>
</tr>
<tr>
<td><span style="display:inline-block;width:100px;text-align:left;font-size:1.2em;padding-top:5px;padding-bottom:5px;">密码: </span><?php echo $form->passwordField($user,'password')?></td>
</tr>
<tr>
<td><span style="display:inline-block;width:100px;margin-left:100px;text-align:left;font-size:1.2em;padding-top:5px;padding-bottom:5px;">角色选择: </span>
<?php $roles=array('0'=>'医生','2'=>'老师','3'=>'军人','4'=>'动漫','5'=>'通话');echo $form->checkBoxList($user,'roles[]',$roles,array('separator'=>' ','style'=>'display:inline-block;'));?></td>
</tr>
<tr>
<td style="padding-top:5px;padding-bottom:5px;"><input type="submit" name="edit" style="width:100px;" class="btn btn-primary" value="添加"></td>
</tr>
</table>
<?php $this->endWidget()?>

   其中checkbox横排显示可以在style中加入display:inline-block

yii表单的更多相关文章

  1. Yii表单模型使用及以数组形式提交表单数据

    按Yii文档里的描述,Yii在处理表单的一般过程是: 创建表单对应的模型类,设置字段验证规则 创建表单提交对应的action,处理提交的内容 在视图中创建表单form 在刚刚的一个小项目里,想使用aj ...

  2. Yii 表单验证规则---总结

    Filter: 过滤,'filter'=>'trim',表示去空格 Required:必须的,表示不能为空 Match: 匹配正则,需要和pattern一起使用,定义正则表达式,'pattern ...

  3. yii表单输入元素

    InputElement http://www.yiichina.com/api/CFormInputElement CFormInputElement 可以代表以下基于type属性的表单输入类型: ...

  4. YII 表单验证规则

    官方文档:http://www.yiichina.com/guide/form.model 类参考手册:http://www.yiichina.com/api/CValidatorhttp://www ...

  5. yii 表单小部件使用

    首先创建model层 因为要使用表单小部件 所以要加载相应的组件 这里需要的组件有 yii\widgets\ActiveForm 和 yii\helpers\Html 接下来在model定义的clas ...

  6. [moka同学笔记]yii表单dropdownlist样式

    <?= $form->field($modelUser,'name') ?> <div class="form-group field-community-mobil ...

  7. Yii表单验证

    我之前在朋友的公司拿到他们oa的代码,发现是用Yii写的,oa系统比较简单,但是程序员对Yii的运用比较好,我拿来学习一下.如果有需要,我可以私下分享这个程序,因为是人家的功劳,不在网上公布代码了,只 ...

  8. yii 表单如何写,action指向哪里?

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

  9. yii表单的各种验证

    /验证规则详细配置 public function rules() { // NOTE: you should only define rules for those attributes that ...

随机推荐

  1. 算法--数组中出现一次的数,其余都出现N次

    转载:http://blog.csdn.net/morewindows/article/details/12684497 题目:数组A中,除了某一个数字x之外,其他数字都出现了三次,而x出现了一次.请 ...

  2. 回车键Enter

    兼容IE与firefox火狐的回车事件(js与jquery) 原生Javascript写法: <script> document.onkeydown=function(event) { e ...

  3. 使用ContentProvider管理多媒体-----向多媒体数据中添加数据

    //为add按钮的单击事件绑定监听器 add.setOnClickListener(new OnClickListener() { @Override public void onClick(View ...

  4. 使用drawBitmapMesh扭曲图像

    Canvas提供了一个drawBitmapMesh(bitmap, meshWidth, meshHeight, verts, vertOffset, colors, colorOffset, pai ...

  5. C#压缩图片1

    using System;using System.Collections.Generic;using System.Drawing;using System.Drawing.Drawing2D;us ...

  6. Javascript arguments详解

    今天我们来看看arguments对象及属性.arguments对象不能显式创建,arguments对象只有函数开始时才可用.函数的 arguments 对象并不是一个数组,访问单个参数的方式与访问数组 ...

  7. ubuntu 下串口调试工具 minicom安装与配置cutecom安装

    安装minicom:     $sudo apt-get install minicom 配置minicom:    如果您的系统的默认语言不是英文,请执行下面的命令:     $LANG=EN    ...

  8. 项目管理软件---redmine安装配置

    redmine是一个开源的项目管理软件,其主页是:http://www.redmine.org redmine是基于Ruby on Rails框架的,跨平台和跨数据库. 安装过程 ========== ...

  9. C#特性

    一.概念:C#的特性也是一个类,继承自System.Attribute,用于描述类.方法.字段等 二.类型:   2.1  .net中特性用来处理多种问题,比如序列化.程序的安全特性.防止即时编译器对 ...

  10. 《day12---异常》

    //91-面向对象-异常-异常的发生和简单应用. /* 异常: java运行时期发生的问题就是异常. Java中运行时的除了异常Exception含有错误Error. 异常:通常发生后可以有针对性的处 ...