<td colspan="2" align="center">
    <h2>{$params_tpl['title']}{$params_tpl['help']}</h2>
    <div style="display: flex; flex-direction: column;">{$tpl_types['themes']}</div>
    <div style="display: flex; flex-direction: column;">
        <div class="correlation__row">
            <div class="correlation__key">Получатель<span class="help_bt" h_id="recipient"></span>:</div>
            <div style="text-align: left; display: flex; flex-direction: column;">
                <p style="margin: 5px 0 0 0;"><input style="margin: 0 5px 2px 0;" type="radio" id="sender_{$tpl_num}" name="sender_{$tpl_num}" value="1">Фиксированный</p>
                <p style="margin: 0 0 5px 0;"><input style="margin: 0 5px 2px 0;" type="radio" name="sender_{$tpl_num}" value="2">Из поля</p>
            </div>
        </div>
    </div>
    <div id="to_mail_str_{$tpl_num}" style="display: flex; flex-direction: column;">{$tpl_types['to_mail_str']}</div>
    <div id="to_mail_field_{$tpl_num}" style="display: flex; flex-direction: column;">{$tpl_types['to_mail_field']}</div>
    <div style="display: flex; flex-direction: column;">{$tpl_types['from_mail']}</div>
    <div style="display: flex; flex-direction: column;">{$tpl_types['name']}</div>
    <div style="display: none; flex-direction: column;">{$tpl_types['radio']}</div>
</td>

<script>
(function() {
    $('select[name="calc_params[{$tpl_num}][to_mail_field]"]').css('width', '150px');
    let checked = $('input[name="calc_params[{$tpl_num}][radio]"]').val();
    edit_button_form.sender_{$tpl_num}.value = checked == 2 ? 2 : 1;

    function modifyDisplayNoneForRadioButton() {
        let num = edit_button_form.sender_{$tpl_num}.value;
        $('input[name="calc_params[{$tpl_num}][radio]"]').val(num);
        if (num == 1) {
            $('#to_mail_str_{$tpl_num}').css('display', '');
            $('#to_mail_field_{$tpl_num}').css('display', 'none');
        } else {
            $('#to_mail_str_{$tpl_num}').css('display', 'none');
            $('#to_mail_field_{$tpl_num}').css('display', '');
        }
    }

    $('input[name="sender_{$tpl_num}"]').on('change', modifyDisplayNoneForRadioButton);
    modifyDisplayNoneForRadioButton();
})();
</script>
