Reputation: 436
$records_skincolor1 = array('Black'=> 'Black','Brown'=> 'Brown','Dark Brown'=> 'Dark Brown','Blue'=> 'Blue','Grey Blue'=> 'Grey Blue','Hazel'=> 'Hazel','True Green'=> 'True Green');
echo CHtml::checkBoxList('Superadvancesearch[talent_skincolor][]','',$records_skincolor1, array(
'template'=><li>{input}{label}</li>,
'separator'=>'',
));
I need to remove label for
attribute. How to remove it.
Upvotes: 0
Views: 1083
Reputation: 8607
If you use Yii 1.1.14 you can use the new beginLabel
, labelTitle
and endLabel
placeholder. In this case, no for
will be rendered:
'template' => '{input}{beginLabel}{labelTitle}{endLabel}'
But to be honest I can hardly see a reason why you would want to remove this attribute. Because then you can't click the label anymore to check/uncheck a checkbox. Maybe your rather look for surrounding labels:
'template' => '{beginLabel}{input}{labelTitle}{endLabel}'
This is how Bootstrap expects checkboxes and here the label can still be clicked to check/uncheck the checkbox.
The same works for radiobuttons, too, BTW.
Upvotes: 1
Reputation: 7265
you can do this:
you are giving an array to your CHtml::checkBoxList method.
you just define the array before this method and make it with your condition.
if ($value == $someValue)
$yourArray=array(
'template'=><li>{input}{label}</li>,
'separator'=>'',);
else
$yourArray=array(
'template'=><li>{input}</li>,
'separator'=>'',);
and give this to your method:
echo CHtml::checkBoxList('Superadvancesearch[talent_skincolor][]','',$records_skincolor1, $yourArray
));
cheers.
Upvotes: 0