yii框架中的CHtml::activeRadioButtonList生成的单选框禁止换行的方法

来源:互联网 发布:mac破解软件论坛 编辑:程序博客网 时间:2024/05/20 16:32
最近在用yii框架开发一个项目,发现这个项目非常强大,而且非常的容易上手,建议php爱好者去学习一下。 用的时候遇到一个问题,就CHtml::activeRadioButtonList生成的单选框总是分成两行,看起来很舒服,后来去看了一下他的源码,发现他默认输出的是带有label标签的,我个人是把这个label标签换成span标签。 使用方法: $sex_radiobuttonList = CHtml::activeRadioButtonList($model,’sex’,array(‘0'=>'男士','1'=>'女士'), 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’,'0');
原创粉丝点击