php - Cakephp set default value for multiple checkbox subgroups -


how set default selected checkboxes when using "sub-groups" of checkboxes? can achieve so-called "sub-groups" having nested array 'options' attribute. want have checkboxes selected default.

echo $this->form->input('foobar', [     'type' => 'select',     'multiple' => 'checkbox',     'label' => false,     'class' => 'inlineblock',     'options' => [         'foo' => [0 => 'yes', 1 => 'no' ]         'bar' => [0 => 'one', 1 => 'two', 2 => 'three'] ]]); 

i've tried setting

'selected' => [0 => [0, 1], 0 => [0, 1, 2]]

and

'checked' => true

but no luck. if check them manually , submit form, cakephp generates url parameters if there no "sub-groups", e.g.:

'options' => [0 => 'yes', 1 => 'no' ]

which same behaviou if set

'default' => [1, 2, 3]

is possible set selected checkboxes of individual checkbox "sub-groups"?

you need use 'val' attributes below :

                    <?= $this->form->control("themes._ids", [                         "label" => false,                         'multiple' => 'checkbox',                         "val" => [1, 2, 3]                     ]) ?> 

reference api doc


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo