Possible fix for CHtml::checkBoxList

I was not sure where the best topic is to post this message so I decided to post under bug reports.

When rendering checkBoxList CHtml uses a template "{input} {label}". This results in a form line like

<input id="info0" value="1" type="checkbox" name="info[]" /> <label for="info0">ITEMLABEL</label>

But label tag writes the label text to a new line after checkbox. So items are displayed like:

X

ITEMLABEL

X

ITEMLABEL

Its probably possible to fix this by css but in order to have a correct view in basic html layout, CHtml can be changed like following (CHtml lines 857-859):

Current Version:




$option=self::checkBox($name,$checked,$htmlOptions);

$label=self::label($label,$htmlOptions['id'],$labelOptions);

$items[]=strtr($template,array('{input}'=>$option,'{label}'=>$label));



Version that renders label text and checkbox in label tag.




$option=self::checkBox($name,$checked,$htmlOptions);

$template=self::label($template,$htmlOptions['id'],$labelOptions);

$items[]=strtr($template,array('{input}'=>$option,'{label}'=>$label));



I always make this change after installing a new version of yii and I hope this change can be applied to upcoming versions.

you dont need to do that….you can use:

‘labelOptions’=>array(‘style’=>‘display:inline’)

:)

thanks it’s good!

Works as it should, great! thanks!