<?php
// Copyright 1999-2022. Plesk International GmbH. All rights reserved.
?>
<?php $selectElement = $this->form->getElement('actionType'); ?>

<div class="form-row">
    <div class='field-name'>
        <?php echo $this->elementPart($selectElement)->label(); ?>
        <?= $this->requiredMark($this->isRequired) ?>
    </div>
    <div class="field-value">
        <div class="text-value">
            <?php foreach ($selectElement->getMultiOptions() as $optionName => $optionTitle):?>
                <div class="indent-box">

                    <input type="radio" class="radio"
                        value="<?php echo $optionName; ?>"
                        id="<?php echo $selectElement->getId() . "-$optionName"; ?>"
                        name="<?php echo $selectElement->getFullyQualifiedName(); ?>"
                        <?php echo ($optionName == $selectElement->getValue()) ? 'checked="checked"' : ''; ?>
                    />

                    <div class="indent-box-content">
                        <label for="<?php echo $selectElement->getId() . "-$optionName"; ?>"><?php echo $optionTitle; ?></label>
                        <?php if ('new' == $optionName): ?>
                            <?php $newNameElement = $this->form->getElement('newName'); ?>
                            <div class='form-row<?php echo $newNameElement->hasErrors() ? ' error' : '';?>'>
                                <div class="nowrap">
                                    <span id="databasePrefix" class="field-prefix"><?php echo $newNameElement->getAttrib('prefix'); ?></span>
                                    <?php echo $this->elementPart($newNameElement)->content(); ?>
                                </div>
                                <span class='field-errors'<?php echo $newNameElement->hasErrors() ? '' : ' style="display:none;"';?>>
                                    <?php echo $this->elementPart($newNameElement)->errors();?>
                                </span>
                            </div>
                        <?php else: ?>
                            <?php $existingDatabasesElement = $this->form->getElement('existingDatabase'); ?>
                            <div class='form-row<?php echo $existingDatabasesElement->hasErrors() ? ' error' : '';?>'>
                                <div><?php echo $this->elementPart($existingDatabasesElement)->content(); ?></div>
                                <span class='field-errors'<?php echo $existingDatabasesElement->hasErrors() ? '' : ' style="display:none;"';?>>
                                    <?php echo $this->elementPart($existingDatabasesElement)->errors();?>
                                </span>
                            </div>
                        <?php endif; ?>
                    </div>

                </div>
            <?php endforeach;?>
        </div>
    </div>
</div>
