Skip to main content

fields/checkbox.php

This snippet renders checkbox groups for forms, allowing users to select multiple options.

Default

You can overwrite this snippet by placing a custom version in site/snippets/email-manager/fields/checkbox.php.

Modify the CSS classes or structure to match your project’s requirements.

<?php foreach ($options as $key => $label): ?>
    <div class="checkbox-option">
        <input 
            type="checkbox" 
            id="<?= $key ?>" 
            name="<?= $field->name() ?>[]" 
            value="<?= $key ?>" <?= in_array($key, (array) $field->value()) ? 'checked' : '' ?>>
        <label for="<?= $key ?>"><?= $label ?></label>
    </div>
<?php endforeach; ?>