I want to make my checkbox defaultly checked in admin form, I add checkbox field using fieldset using below code :
foreach ($services as $service) {
$servCond = false;
if(is_array($chosenServ)){
if(in_array($service['courierservices_id'],$chosenServ)){
$servCond = true;
}
}
$value['value'] = $service['courierservices_id'];
$value['label'] = $service['description'];
$value['checked'] = $servCond;
$values[] = $value;
}
$fieldset->addField(
'courierservice'.$i,
'checkboxes',
[
'name' => _('courier_service'.$i.'[]'),
'label' => __('Services : '),
'values' => $values,
'checked' => true
]
);
$i++;