<div>
    <div class="ml20">
        <ul class="list-style-none m0 p0" id="checkboxesSelection__C__CATG__CUSTOM__[{$key}]">
            [{foreach $field.p_arData as $ardata_id => $ardata_elem}]
            <li class="mb5">
                <label>
                    <input
                        type="checkbox"
                        class="C__CATG__CUSTOM__[{$key}] mr5"
                        name="C__CATG__CUSTOM__[{$key}][[{$ardata_id}]]"
                        id="C__CATG__CUSTOM__[{$key}]__[{$ardata_elem.id}]"
                        value="[{$ardata_elem.id}]"
                        [{if !isys_glob_is_edit_mode()}]disabled[{/if}]
                        [{if in_array($ardata_elem.id, $field.values)}]checked[{/if}] /><span>[{$ardata_elem.title}]</span>
                </label>
            </li>
            [{/foreach}]
        </ul>

        [{if isys_glob_is_edit_mode() && $field.authorizedToEdit}]
        <button type="button" class="C__CATG__CUSTOM__[{$key}] mt5 btn" onclick="get_popup('dialog_plus','','480','70%',{params:'[{$field.params}]'},null,null,null,null,null);">
            <img src="[{$dir_images}]axialis/basic/pages-stack.svg" alt=""><span>[{isys type="lang" ident="LC__UNIVERSAL__NEW_VALUE"}]</span>
        </button>
        [{/if}]
    </div>


    <div class="hide">
        <select id="C__CATG__CUSTOM__[{$key}]" data-identifier="isys_cmdb_dao_category_g_custom_fields::f_popup_[{$key}]" data-output-type="checkboxes" multiple="multiple">
            [{foreach $field.p_arData as $ardata_id => $ardata_elem}]
            <option value="[{$ardata_elem.id}]" [{if in_array($ardata_elem.id, $field.values)}] selected="selected" [{/if}]>[{$ardata_elem.title}]</option>
            [{/foreach}]
        </select>

        <input type="hidden" name="SM2__C__CATG__CUSTOM__[{$key}][p_strPopupType]" value="checkboxes">
        <input type="hidden" name="SM2__C__CATG__CUSTOM__[{$key}][p_strSelectedID]" id="SM2__C__CATG__CUSTOM__[{$key}]__p_strSelectedID" />
        <input type="hidden" name="SM2__C__CATG__CUSTOM__[{$key}][p_strTable]" value="isys_dialog_plus_custom" />
        <input type="hidden" name="SM2__C__CATG__CUSTOM__[{$key}][multiselect]" value="1" />
        <input type="hidden" name="SM2__C__CATG__CUSTOM__[{$key}][p_arData]" value="">
        <input type="hidden" name="SM2__C__CATG__CUSTOM__[{$key}][p_strValue]" value="">
        <input type="hidden" name="SM2__C__CATG__CUSTOM__[{$key}][type]" value="f_popup">
    </div>

    <script type="text/javascript">
        (function () {
            'use strict';

            [{if isys_glob_is_edit_mode()}]
            reloadSmartySelection();
            [{else}]
            document.observe("dom:loaded", function() {
                reloadSmartySelection()
            });
            [{/if}]

            function reloadSmartySelection() {
                $('SM2__C__CATG__CUSTOM__[{$key}]__p_strSelectedID').setValue($$('input.C__CATG__CUSTOM__[{$key}]:checked').invoke('getValue').join(','));
            }
        })();
    </script>
</div>