CakePHP3 Multi Checkbox custom attribute

507 views Asked by At

I am using the the Cake

<?= $this->Form->input('vehicles._ids', ['label' => 'Vehicle', 'options' => $vehicles, 'multiple' => 'checkbox', 'ng-model' => 'vehicles']); ?>

For each check box I want to add the custom attributes: 'ng-model'

I can see that the generation of multiple checkboxes is handled by the class file MultiCheckboxwidget.php and checkboxes use the 'checkbox' template:

'checkbox' => '<input type="checkbox" name="{{name}}" value="{{value}}"{{attrs}}>',

But since by default this uses {{attrs}} I can't see why my custom ng-model attribute isn't being added to the generatred form input. Instead this is the amrk-up crearted by the helper:

<input type="checkbox" name="vehicles[_ids][]" value="1"id="vehicles-ids-1" class="ng-valid">

How can I add ng-model to each of the checkbox inputs?

1

There are 1 answers

0
Alan A On

Upgrading my verison of CakePHP form 3.3.12 to 3.4 resolved the issue, the formhelper must have been refined in the latter versions.