Tuesday, November 12, 2013

How to add class at checkbox in cakePHP 2.0?

How to add class at check box.?

Code
echo $this->Form->select('user_list', $user_options, array(
'multiple' => 'checkbox',
'name' => 'data[GroupUser][user_id]',
'class' => 'validate[maxCheckbox[1]]',));

output:-
<div class="validate[maxCheckbox[1]]"><input type="checkbox" id="GroupUserList1" value="1" name="data[GroupUser][user_id][]"><label for="GroupUserList1">rahim basheer</label></div>
<div class="validate[maxCheckbox[1]]"><input type="checkbox" id="GroupUserList3" value="3" name="data[GroupUser][user_id][]"><label for="GroupUserList3">ram kumar</label></div>
<div class="validate[maxCheckbox[1]]"><input type="checkbox" id="GroupUserList5" value="5" name="data[GroupUser][user_id][]"><label for="GroupUserList5">riyas khan</label></div>
<div class="validate[maxCheckbox[1]]"><input type="checkbox" id="GroupUserList6" value="6" name="data[GroupUser][user_id][]"><label for="GroupUserList6">ramesh krishna</label></div>

I need the following format of output:-
<div><input class="validate[maxCheckbox[1]]" type="checkbox" id="GroupUserList1" value="1" name="data[GroupUser][user_id][]"><label for="GroupUserList1">rahim basheer</label></div>
<div><input class="validate[maxCheckbox[1]]" type="checkbox" id="GroupUserList3" value="3" name="data[GroupUser][user_id][]"><label for="GroupUserList3">ram kumar</label></div>
<div><input class="validate[maxCheckbox[1]]" type="checkbox" id="GroupUserList5" value="5" name="data[GroupUser][user_id][]"><label for="GroupUserList5">riyas khan</label></div>
<div><input class="validate[maxCheckbox[1]]" type="checkbox" id="GroupUserList6" value="6" name="data[GroupUser][user_id][]"><label for="GroupUserList6">ramesh krishna</label></div>

Thanks 
Kushal


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: