<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/**
 * @var $block \Magento\CurrencySymbol\Block\Adminhtml\System\Currencysymbol
 * @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
 */
?>

<form id="currency-symbols-form" action="<?= $block->escapeUrl($block->getFormActionUrl()) ?>" method="post">
    <input name="form_key" type="hidden" value="<?= $block->escapeHtmlAttr($block->getFormKey()) ?>" />
    <fieldset class="admin__fieldset">
        <?php foreach ($block->getCurrencySymbolsData() as $code => $data): ?>
        <div class="admin__field _required">
            <label class="admin__field-label" for="custom_currency_symbol<?= $block->escapeHtmlAttr($code) ?>">
                <span><?= $block->escapeHtml($code) ?> (<?= $block->escapeHtml($data['displayName']) ?>)</span>
            </label>
            <div class="admin__field-control">
                <input id="custom_currency_symbol<?= $block->escapeHtmlAttr($code) ?>"
                       class="required-entry admin__control-text"
                       type="text"
                       value="<?= $block->escapeHtmlAttr($data['displaySymbol']) ?>"
                       name="custom_currency_symbol[<?= $block->escapeHtmlAttr($code) ?>]"
                        <?= $data['inherited'] ? 'disabled' : '' ?>>
                <div class="admin__field admin__field-option">
                    <?php
                        $escapedCode = $block->escapeHtmlAttr($block->escapeJs($code));
                        $escapedSymbol = $block->escapeJs($data['parentSymbol']);
                    ?>
                    <input id="custom_currency_symbol_inherit<?= $block->escapeHtmlAttr($code) ?>"
                           class="admin__control-checkbox" type="checkbox"
                            <?= $data['inherited'] ? ' checked="checked"' : '' ?>
                           value="1"
                           name="inherit_custom_currency_symbol[<?= $block->escapeHtmlAttr($code) ?>]">
                    <label class="admin__field-label"
                           for="custom_currency_symbol_inherit<?= $block->escapeHtmlAttr($code) ?>">
                        <span>
                            <?= $block->escapeHtml($block->getInheritText()) ?>
                        </span>
                    </label>
                    <?= /* @noEscape */ $secureRenderer->renderEventListenerAsTag(
                        'onclick',
                        "toggleUseDefault('" . $escapedCode . "','" . $escapedSymbol . "')",
                        '#custom_currency_symbol_inherit' . $block->escapeJs($code)
                    ) ?>
                </div>
            </div>
        </div>
        <?php endforeach; ?>
    </fieldset>
</form>
<script type="text/x-magento-init">
    {
        "#currency-symbols-form": {
            "Magento_CurrencySymbol/js/symbols-form": {}
        }
    }
</script>
