<?php
// Copyright 1999-2024. WebPros International GmbH. All rights reserved.
?>
<div id='<?php echo $this->element->getId(); ?>-form-row' class='form-row'>
    <div class='field-name'>
        <?php echo $this->element->getLabel(); ?>
        <?= $this->requiredMark($this->element->isRequired()) ?>
    </div>
    <div class='field-value'>
        <span>
            <?php echo $this->elementPart($this->element)->content(); ?>
        </span>
        <span class="field-errors" style="display: none;"></span>
        <?php if ($this->element->getDescription()): ?>
            <span class="hint"><?php echo $this->element->getDescription(); ?></span>
        <?php endif; ?>
    </div>
</div>
<script type="text/javascript">
//<![CDATA[
Jsw.onReady(function () {
    var updateState = function () {
        var elementToShow = 'typesForms-' + $F('<?php echo $this->element->getId(); ?>') + 'Type';
        document.getElementById('typesForms-content-area').querySelectorAll('div.form-box').forEach(function (element) {
            element.style.display = 'none';
        });
        document.getElementById(elementToShow).style.display = '';
    }

    updateState();
    document.getElementById('<?php echo $this->element->getId(); ?>').addEventListener('change', updateState);
});
//]]>
</script>
