Q:

CakePHP: multiple checkbox with different html attribute

Here is the situation: 
i have table stages having following structure
 | id              |  name                                         | editable|
 -----------------------------------------------------------------------------
 | open            | Open                                          |    1    | 
 | paysheet_review | Paysheet Submitted (Awaiting Office Approval) |    0    | 
 | to_pay          | Paysheet Approved (Awaiting Payment)          |    0    | 
 | paid            | Paid                                          |    1    | 
 | purgatory       | Flip or Refund                                |    0    | 
 | closed          | Deal Closed                                   |    1    |
 -----------------------------------------------------------------------------

I am creating a multiple checkbox block by
In Controller
<?php $_stages = $this->Stage->find("list");?>

In View
<?php echo $this->Form->input("stage", array("multiple" => "checkbox", "options" => $_stages));?>

which creates following html
<div class="control-group">
 <label class="control-label" for="DealStage">Stage</label>
   <input type="hidden" value="" id="DealStage_" name="data[Deal][stage]">
 <div class="controls">
    <label class="checkbox"><input type="checkbox" id="DealStageOpen" value="open" name="data[Deal][stage][]">Open</label>
    <label class="checkbox"><input type="checkbox" id="DealStagePaysheetReview" value="paysheet_review" name="data[Deal][stage][]">Paysheet Submitted (Awaiting Office Approval)</label>
    <label class="checkbox"><input type="checkbox" id="DealStageToPay" value="to_pay" name="data[Deal][stage][]">Paysheet Approved (Awaiting Payment)</label>
    <label class="checkbox"><input type="checkbox" id="DealStagesPaid" value="paid" name="data[Deal][stage][]">Paid</label>
    <label class="checkbox"><input type="checkbox" id="DealStagePurgatory" value="purgatory" name="data[Deal][stage][]">Flip or Refund</label>
    <label class="checkbox"><input type="checkbox" id="DealStageClosed" value="closed" name="data[Deal][stage][]">Deal Closed</label>
  </div>
</div>

Now I want to pass the editablefrom Database column as a title for each checkbox. 
Is there any way that we create a multiple checkbox in CakePHP and add a title as attribute to each input type checkbox. so that I can use jQuery to check OR uncheck only editable Stages.

A:

Generate individual checkboxes
There's no means to give individual attributes to a checkbox if they are generated in one call, however it's easily achievable generating each checkbox individually. To do so ensure that the stages data is passed to the view:
// in Controller action
$stages = $this->Stage->find("all");
$this->set('stages', $stages);

And in the view simply iterate over the $stages variable to generate checkboxes:
// in view file
foreach ($stages as $stage) {
     $id = $stage['Stage']['id'];
     $name = $stage['Stage']['name'];
     $editable  = $stage['Stage']['editable'];

     echo $this->Form->input(
         'Deal.stage.' . $id,
         ['value' => $id, 'label' => $name, 'type' => 'checkbox', 'data-editable' => $editable]
     );
}

I don't quite follow what you want to do with this editable property - but to access it from js it would then be:
// in js file
$('input[type=checkbox]'].each(function() {
    var editable = $(this).data('editable');

    ...
});

