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
This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
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; ?>
1-5 of 5