Adding class to multiple checkboxes [Solved]


#1

I’m creating multiple checkboxes for a BelongsToMany association. The checkboxes generate correctly, with the existing associations already checked, however, it seems to be ignoring the class I’m trying to apply to them. What is the correct way to apply the class to all the generated checkbox inputs.

Here’s is the code that generates the checkboxes:

$this->Form->input(‘foos._ids’, [‘multiple’ => ‘checkbox’, ‘class’ => ‘my_class’]);

I’ve tried setting the checkbox template to <input type=“checkbox” class=“my_class” name="{{name}}" value="{{value}}"{{attrs}}>

But that just caused form helper to spit out several errors regarding trying to treat an array as a string.

EDIT: I’ve solved it. I was attempting to set the template wrong. I’m still using 3.3.x, but was following the 3.4 documentation which no longer mentions the combined getter/setter $this->Form->templates().