<?php $this->extend('form_row'); ?>

<?php $this->block('field'); ?>
<fieldset id="ctrl_<?= $this->id ?>" class="checkbox_container<?php if ($this->class) echo ' ' . $this->class; ?>">

    <?php if ($this->label): ?>
    <legend>
        <?php if ($this->mandatory): ?>
        <span class="invisible"><?= $this->mandatoryField ?> </span><?= $this->label ?><span class="mandatory">*</span>
        <?php else: ?>
        <?= $this->label ?>
        <?php endif; ?>
    </legend>
    <?php endif; ?>

    <?php if ($this->hasErrors()): ?>
    <p class="error"><?= $this->getErrorAsString() ?></p>
    <?php endif; ?>

    <input type="hidden" name="<?= $this->name ?>" value="">

    <?php foreach ($this->getOptions() as $option): ?>
    <?php if ($option['type'] == 'group_start'): ?>
    <fieldset>
        <legend><?= $option['label'] ?></legend>
        <?php endif; ?>

        <?php if ($option['type'] == 'option'): ?>
        <label id="lbl_<?= $option['id'] ?>" for="opt_<?= $option['id'] ?>">
            <input type="checkbox" name="<?= $option['name'] ?>" id="opt_<?= $option['id'] ?>" class="checkbox" value="<?= $option['value'] ?>"<?= $option['checked'] ?><?= $option['attributes'] ?>>
            <span><?= $option['label'] ?></span>
        </label>
        <?php endif; ?>

        <?php if ($option['type'] == 'group_end'): ?>
    </fieldset>
    <?php endif; ?>
    <?php endforeach; ?>

</fieldset>
<?php $this->endblock(); ?>
