Saturday, October 2, 2010

Change id for checkboxes

Hi there,

I'm using the form helper to create checkboxes this way :

<?php echo $form->input('Group',
array(
'label' => 'Group',
'type' => 'select',
'multiple' => 'checkbox',
'options' => array(1 => 'Pilot', 2 => 'Medical', 3 => 'Other'),
'id' => 11)
);
?>

and I then obtain :

<div class="input select">
<label for="GroupGroup">Group</label>
<input type="hidden" name="data[Group][Group]" value="" id="11" />
<div class="checkbox">
<input type="checkbox" name="data[Group][Group][]" value="1"
id="GroupGroup1" />
<label for="GroupGroup1">Pilot</label>
</div>
<div class="checkbox">
<input type="checkbox" name="data[Group][Group][]" value="2"
id="GroupGroup2" />
<label for="GroupGroup2">Medical</label>
</div>
<div class="checkbox">
<input type="checkbox" name="data[Group][Group][]" value="3"
id="GroupGroup3" />
<label for="GroupGroup3">Other</label>
</div>
</div>

So far so good right? But now I would like to have the id set to 11
not only for the global input tag, but for EVERY input tag, which
would output this :

<div class="input select">
<label for="GroupGroup">Group</label>
<input type="hidden" name="data[Group][Group]" value="" id="11" />
<div class="checkbox">
<input type="checkbox" name="data[Group][Group][]" value="1" id="11" /
>
<label for="GroupGroup1">Pilot</label>
</div>
<div class="checkbox">
<input type="checkbox" name="data[Group][Group][]" value="2" id="11" /
>
<label for="GroupGroup2">Medical</label>
</div>
<div class="checkbox">
<input type="checkbox" name="data[Group][Group][]" value="3" id="11" /
>
<label for="GroupGroup3">Other</label>
</div>
</div>

BUT, I can't find a way to do that.

Is there a way to set the id for each checkbox, just like we do for
the values and the labels???

Thanks in advance

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: