Checkbox not getting displayed

Hello All,

I have yii form which has a checkbox.

The code is like this -


echo "<input name='actions[]' value='$value' type='checkbox' />";

But in view source I can see -


<input name="actions[]" value="List" type="checkbox" style="display: none;">

Because of the style, checkbox is not getting displayed.

I have tried something like this with no luck -


echo CHtml::CheckBox('actions[]', '', array('value'=>$key));

Please help.

Thank you!!

Have you tried to use CActiveForm::checkbox instead?




<div class="row rememberMe">

	<?php echo $form->labelEx($model,'attribute'); ?>

	<?php echo $form->checkBox($model,'attribute'); ?>

	<?php echo $form->error($model,'attribute'); ?>

</div>

http://www.yiiframework.com/doc/api/1.1/CActiveForm#checkBox-detail

Thank you moginn for the reply.

I do not have model here and I want to have checkbox array.

How can I do it?

Thank you!

to print several checkboxes you should use CHtml::checkboxlist

http://www.yiiframework.com/doc/api/1.1/CHtml#checkBoxList-detail

try the checkBoxList

http://www.yiiframework.com/doc/api/1.1/CHtml#checkBoxList-detail

Try this

Checkbox

Try this

Checkbox

What U need here is :

http://www.yiiframework.com/doc/api/1.1/CHtml#checkBoxList-detail

1 Like

Thank you very much to all of you for the replies.

My scenario is quiet complex,

The html code looks like this -

So its difficult to use checkbox list box.

And I can not give different checkbox list names to different checkbox blocks as shown between the texts and other html elements.

I have to make it work using checkbox only.

Thank you!