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
时间: 2024-11-03 21:35:44