Unfortunately, I cannot find a way to add attributes to $options as you want. What I usually do is simply perform this role manually, forget FormHelper and write the old html.
If this is not an option for you, and you want to continue to use Formhelper for this, I can suggest a js approach.
First you need to change find('list') to find('all') to get an editable attribute.
<?php $_stages = $this->Stage->find("all");?>
and pass it on to the view. Now in the view you need to change the array so that it looks like old
<?php $stageHelper = array(); foreach($_stages as $stage) $stageHelper[$stage['Stage']['id']] = $stage['Stage']['name']; echo $this->Form->input("stage", array("multiple" => "checkbox", "options" => stageHelper)); ?>
So far, you have the same thing as now. This is where js comes in. In the view below, preferably add something like
<script type="text/javascript"> $(function() { var stages = <?=json_encode($_stages);?>; $('name="data[Deal][stage][]"').each(function() { var currentElement = $(this); var value = currentElement.val();
Something along these lines should be done.
Personally, I find it less difficult to do this with html only. But there is an alternative approach to do this if you want it.
source share