This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hello. I bring the form to edit the product. Product table is a field that holds an array with values such as [1,3,6]. in the form of editing (creating) the product has checkboxes for example, 5 pieces. please tell me how to specify the attribute of the checkbox is selected in the form if its value matches the value of the array [1,3,6] ie I need to fill in thank you
Something like this?
<?php
$prod_id = 3;
$arr = [1, 3, 6];
?>
<?php foreach($arr as $val) : ?>
<input type='checkbox' name='some_name' value='<?= $val; ?>' <?= ($val == $prod_id) ? 'checked' : ''; ?> > <?= $val; ?>
<?php endforeach; ?>
prescribed form setting file - fields.yaml
fields:
language:
label: Language
type: checkboxlist
options: listLanguages
curencys:
label: Curencys
span: left
support:
label: Support
span: left
mobile:
label: Mobile Versions
span: right
Last updated
Aren't the checked values saved within the product model, therefore, when you revisit the product after saving, the checked boxes in the list remain checked?
1-5 of 5