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

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

    <?php $this->block('help'); ?>
    <?= $this->layout->renderHelpText($this->widget) ?>
    <?php $this->endblock(); ?>

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

    <?php foreach (\Netzmacht\Contao\FormDesigner\Util\WidgetUtil::getOptions($this->widget) as $option): ?>
        <?php if ($option['type'] == 'group_start'): ?>
            <fieldset>
            <legend><?= $option['label'] ?></legend>
        <?php endif; ?>

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

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

</fieldset>
