Pre-fill checkboxes based on CMS data

Is it possible to pre-fill a checkbox based on a CMS switch?

As you will see from my read-only, I have a form and am using custom code for the inputs, so that I can insert CMS data. I can pre-fill the text input with CMS data, but can something similar be done with checkboxes? I set the ‘checked’ attribute to the corresponding CMS switch would work, hoping the switch would output a boolean value, but all of my checkboxes are now checked.

Read-only: Webflow - CMS Checkboxes

To pre-fill a checkbox based on a CMS switch, bind the CMS switch value to a custom data-checked attribute on the checkbox. Then, use JavaScript to read the data-checked value and dynamically set the checked state of the checkbox. This ensures only checkboxes with a true value are marked as checked. Let me know if you’d like help refining this setup.

Thanks, got it working!