This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

rumych9431
rumych9431

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

Daniel81
Daniel81

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; ?>
rumych9431
rumych9431

yes, but the form is output through <?= $this->formRender() ?>

rumych9431
rumych9431

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

Daniel81
Daniel81

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

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.