<?php
/**
 * @var $key string
 * @var $field string
 * @var $args string
 */

$default = true;
?>
<?php if (!empty($field['options'])) { ?>
    <p class="bp-label"><?= $field['label'] ?? "" ?></p>
    <div id="<?= $key ?>" class="bp-radio-group <?= (isset($field['required']) && $field['required']) ? "required-radio" : "" ?>">
        <?php foreach ($field['options'] as $name => $option) { ?>
            <div class="bp-radio-group__inner">
                <label for="<?= $key."_".$name ?>"><?= $option ?></label>
                <input type="<?= $field['type'] ?? "" ?>" <? checked($default, true, false) ?>
                       id="<?= $key."_".$name ?>"
                       data-id="<?= $key ?>"
                       class="<?= $args['class'] ?? "" ?> <?= (isset($field['required']) && $field['required']) ? "required" : "" ?>"
                       name="<?= $key ?>" value="<?= $name ?>">
            </div>
            <?php $default = false ?>
        <?php } ?>
    </div>
    <span id="error-<?= $key ?>" class="bp-form-error <?= apply_filters('bp_hidden_class',
        'hidden') ?>"><?= (isset($field['required']) && $field['required']) ? $field['notice'] : "" ?></span>
<?php } ?>