Reputation: 1804
Am trying to wrap my head around using checkboxlists in the yii framework.
Example: With the dropdownlist I can
<?php echo $form->dropdownlist($model,'fathercattle',array(1=>Yours,2=>Mine,3=>Nobody)); ?>
How do I get a similar effect using the Yii checkboxlists option?The values will be stored and retrieved in a database field as an array?
Secondly how do I get to format it?
Upvotes: 1
Views: 10059
Reputation: 1496
You use the checkboxlist in much the same way as the dropdownlist. Take a look at the activecheckboxlist reference. Also, if you want the data to come from the DB you can use the function CHtml::listData to transform an array of active records into a data array for the activecheckbox.
In regards to your second question, you can format the checkboxlist using the htmlOptions array. Two useful options are:
Upvotes: 6