{if !isset($id)}
    {$id = "categories"}
{/if}

{if $categories|size > intval(ConfigHelper::getConfig('rt.category_selection_checkbox_limit', 0, true))}
    <select id="{$id}" name="{$name_prefix}[]" multiple {tip class="lms-ui-advanced-select-test" trigger=$id}
        {if isset($form)} form="{$form}"{/if}>
        {foreach $categories as $category}
            <option value="{$category.id}"{if $category.checked > 0} selected{/if}>{$category.name}</option>
        {/foreach}
    </select>
{else}
    {foreach $categories as $category}
        <label class="nobr">
            <input class="category-checkbox" type="checkbox" name="{$name_prefix}[{$category.id}]"
                value="{$category.id}"
                {if isset($form)} form="{$form}"{/if}
                {if $category.checked > 0}checked{/if} {tip trigger=$id}>
            {$category.name}
        </label>
    {/foreach}
{/if}
