{if isset($selectedWidget) && isset($selectedWidgetInfo)}
    <div class="form-group">
        {assign var="widgetTemplate" value="main/payments-widgets/{$selectedWidgetInfo["template_name"]}.tpl"}
        {include file=$widgetTemplate status=$status price=$selectedWidgetInfo["price"] currency=$currency widgetId=$selectedWidget["widget_id"]} <br>
        <form method="post" action="/?widget/removeRel">
            <input type="text" hidden="hidden" name="widget_id" value="{$selectedWidget["widget_id"]}">
            <input type="text" hidden="hidden" name="object_id" value="{$selectedWidget["object_id"]}">

            {if $isPermitted}
                <button type="submit" class="no-b px-0">
                    <i class="fa fa-trash"></i> Удалить виджет
                </button>
            {/if}
        </form>

    </div>
{else}
{if $isPermitted}
    <form method="POST" action="/?widget/join">
        <div class="form-group">
            <label for="widgetSelect">Выберите виджет:</label>
            <select id="widgetSelect" name="widget_id" class="form-control" required>
                <option value="">Выберите виджет</option>
                {foreach from=$widgets item=widget}
                    <option value="{$widget.id}" {if isset($selected_widget_id) && $selected_widget_id == $widget.id}selected{/if}>{$widget.name}</option>
                {/foreach}
            </select>

            <input type="text" hidden="hidden" name="object_name" value="{$object_name}">
            <input type="text" hidden="hidden" name="object_id" value="{$object_id}">
        </div><br>

        <div class="form-group">
            <button type="submit" class="btn btn-primary">Выбрать виджет</button>
        </div>
    </form>
{/if}
{/if}
