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. C语言内存分配机制

    内存分配方式有三种: (1)从静态存储区域分配.内存在程序编译的时候就已经分配好,这块内存在程序的整个运行期间都存在.例如全局变量,static变量. (2)在栈上创建.在执行函数时,函数内局部变量的 ...

  2. 转载 浅谈C/C++中的static和extern关键字

    浅谈C/C++中的static和extern关键字 2011-04-21 16:57 海子 博客园 字号:T | T   static是C++中常用的修饰符,它被用来控制变量的存贮方式和可见性.ext ...

  3. C#学习笔记思维导图 一本书22张图

    阅读的书是<21天学通C#>博客中有下载 看看总结之后的模块 全部文件 初步展示 数据存储 继承模块 暂时就这些吧 全部思维导图22张打包下载

  4. LInux软件的卸载和安装(转)

    在linux环境中,尤其是cenos中安装过一些软件,一般是二进制安装与源码安装,现小结一下linux中的安装与卸载. 一.通常Linux应用软件的安装包有三种: 1) tar包,如software- ...

  5. js基础之动画(二)

    一.多物体同时运动 栗子一:多个Div,鼠标移入变高,动态下拉菜单 function startMove(obj,iTarget){  clearInterval(obj.timer); obj.ti ...

  6. 转: html表单中get方式和post方式的区别

    1.Get是用来从服务器上获得数据,而Post是用来向服务器上传递数据.  2.Get将表单中数据的按照variable=value的形式,添加到action所指向的URL后面,并且两者使用“?”连接 ...

  7. hdu 4622 Reincarnation

    http://acm.hdu.edu.cn/showproblem.php?pid=4622 用字典树把每一个字符串对应成一个整数 相同的字符串对应到相同的整数上 把所用的串对应的整数放在一个数组里 ...

  8. Spring框架及IOC容器

    Spring是一个非常活跃的开源框架, 它是一个基于IOC和AOP来构架多层JavaEE系统的框架,它的主要目地是简化企业开发.Spring以一种非侵入式的方式来管理你的代码, Spring提倡”最少 ...

  9. Stern-Brocot树 及 法里级数分析

    Stern-Brocot树产生了所有分子分母互素的分数 从初始0/1 1/0 -> m/n m'/n'出发,不断往中间添加 (m+m')/(n+n')容易推得 n * m' - m * n' = ...

  10. Oracle top N实现

    在Oracle中实现select top N:由于Oracle不支持select top 语句,所以在Oracle中经常是用order by 跟rownum的组合来实现select top n的查询. ...