1

I need to display checkbox in the format as shown below enter image description here And the code used to do this is as shown

<style>
   ul,li {
   margin: 0;
   padding: 0;
   list-style-type: none;
   }
   .orange{
   color: #FF6C00;
   }
   .payment_mode{
   float: left;
   width: 700px;
   margin: 0 0 8px 0;
   padding: 0 0 8px 0;
   }
   .payment_mode ul li{
   float: left;
   width: 220px;
   padding: 3px 0;
   }
   .checkboxgroup{
   overflow:auto;
   }
   .checkboxgroup div{
   width:200px;
   float:left;
   }
</style>

<div class="payment_mode">
   <p>
      <b>Payment Modes Accepted By You</b>
   </p>
   <ul>
      <li><input type="checkbox" onclick="select_all('cb_modes[]')"
         value="All" id="sel_all_modes" name="sel_all_modes" class="cmn"> <span
         class="orange">Select All</span>
      </li>
      <li><input type="checkbox" value="Cash" id="cb_modes[]"
         name="cb_modes[]" class="cmn"> <span>Cash</span>
      </li>
      -----
      -----
   </ul>
</div>

I need to achieve the same thing using checkBoxList i tried using checkBoxList i get it as shown enter image description here

And the code to do that is as shown

<?php echo CHtml::checkBoxList('checkBoxList','',
    CHtml::listData(paymentmode::model()->findAll(), 'paymentmodeid', 'paymentmode'),array('id'=>'checklist','name'=>'checklist',
           )
);?>

1 Answer 1

3

You could use the template option of the checkBoxList():

<ul>
<?php echo CHtml::checkBoxList('checkBoxList','',$data, array(
    'id'=>'checklist',
    'name'=>'checklist',
    'template'=>'<li>{input} {label}</li>',
));?>
</ul>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.