下拉列表用法:
<td align="right" class="hui4">企业性质:</td>
<td align="left" class="hui4">
<?php echo CHtml::activeDropDownList($model,'business_nature',
array('国有'=>'国有',
'民营'=>'民营',
'合资'=>'合资',
'集体'=>'集体',
'其它'=>'其它',
)); ?>
</td>
单选按钮用法:
就CHtml::activeRadioButtonList生成的单选框总是分行,后来去看了一下他的源码,发现他默认输出的是带有label标签的,我个人是把这个label标签换成span标签。
启发:当遇到不好处理的页面时,可通过查看源代码,根据源代码分析页面进行必要的替换!
使用方法:
$sex_radiobuttonList = CHtml::activeRadioButtonList($model,'sex',array('男士'=>'男士','女士'=>'女士'),
array('template'=>'{input}{label}','separator'=>" "));
$sex_radiobuttonList= str_replace("<label", "<span", $sex_radiobuttonList);
$sex_radiobuttonList= str_replace("</label", "</span", $sex_radiobuttonList);
echo $sex_radiobuttonList;
另外,设置首选值也很扁的就可以解决了,在Controller中加入一句话
$model->setAttribute('sex','男士');
<td align="right" class="hui4">成长阶段:</td>
<td align="left" class="hui4">
<?php
$stage = CHtml::activeRadioButtonList($model,'stage',array('种子期'=>'种子期','初创期'=>'初创期','成长期'=>'成长期','发展期'=>'发展期','上市筹备期'=>'上市筹备期'));
$stage= str_replace("<label","<span",$stage);
$stage= str_replace("</label><br","</span",$stage);
echo $stage ;?>
</td>