yii表单

             

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

     

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$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

       

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?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

     

posted @   xshang  阅读(2062)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· [AI/GPT/综述] AI Agent的设计模式综述
点击右上角即可分享
微信分享提示