<#macro dictionaryTree dictionaryId inputName parentValue depth values=''>
<#if depth gt 0>
    <@cms.dictionaryDataList dictionaryId=dictionaryId parentValue=parentValue>
        <#if list?has_content>
        <ul>
            <#list list as d>
                <li>
                    <a tname="${inputName}" tvalue="${d.id.value}"${(values?has_content&&values?seq_contains(d.id.value))?then(' checked="true"','')?no_esc}>${d.text}</a>
                    <@dictionaryTree dictionaryId=dictionaryId inputName=inputName parentValue=d.id.value depth=depth-1 values=values/>
                </li>
            </#list>
        </ul>
        </#if>
    </@cms.dictionaryDataList>
</#if>
</#macro>
<#macro dictionaryElement dictionaryId inputName required childDepth multiple type value=''>
<#assign values=(value?split(','))![]/>
<#if childDepth gt 0>
    <#if multiple>
        <div class="treeForm">
            <ul class="tree treeFolder treeCheck expand">
            <@cms.dictionaryDataList dictionaryId=dictionaryId>
                <#list list as d>
                    <li>
                        <a tname="${inputName}" tvalue="${d.id.value}"${(values?has_content&&values?seq_contains(d.id.value))?then(' checked="true"','')?no_esc}>${d.text}</a>
                        <@dictionaryTree dictionaryId=dictionaryId inputName=inputName parentValue=d.id.value depth=childDepth values=values/>
                    </li>
                </#list>
            </@cms.dictionaryDataList>
            </ul>
        </div>
    <#else>
        <#list 0..childDepth as i>
            <select name="${inputName}" <#if 'customform'!=type>class="combox<#if required> required<#if i gt 0> requiredIfNotEmpty</#if></#if>" ref="${inputName}" index="${i+1}"<#if i lt childDepth> refUrl="common/dictionarySuggest.html?dictionaryId=${dictionaryId}&parentValue={value}"</#if></#if>>
                <option value><@t.page 'please_select'/></option>
            <#if 0=i || parentValue?has_content>
            <@cms.dictionaryDataList dictionaryId=dictionaryId parentValue=parentValue>
                <#assign parentValue=''/>
                <#list list as d>
                    <#if values?has_content&&values?seq_contains(d.id.value)>
                        <#assign parentValue=d.id.value/>
                        <option value="${d.id.value}" selected="true">${d.text}</option>
                    <#else>
                        <option value="${d.id.value}">${d.text}</option>
                    </#if>
                </#list>
            </@cms.dictionaryDataList>
            </#if>
            </select>
        </#list>
    </#if>
<#else>
    <#if multiple>
        <#if 'customform'=type>
        <#noparse><@cms.dictionaryDataList dictionaryId="</#noparse>${dictionaryId}<#noparse>">
            <#list list as d>
                <label>
                    <input name="</#noparse>${inputName}<#noparse>" type="checkbox" value="${d.id.value}" class="form-check-input"/>
                    ${d.text}
                </label>
            </#list>
        </@cms.dictionaryDataList>
        </#noparse>
        <#else>
        <@cms.dictionaryDataList dictionaryId=dictionaryId>
            <#list list as d>
                <label>
                    <input name="${inputName}" type="checkbox" value="${d.id.value}" class="form-check-input"${(values?has_content&&values?seq_contains(d.id.value))?then(' checked="true"','')?no_esc}/>
                    ${d.text}
                </label>
            </#list>
        </@cms.dictionaryDataList>
        </#if>
    <#else>
        <select<#if 'customform'!=type> class="combox<#if required> required</#if>"</#if> name="${inputName}">
            <option value><@t.page 'please_select'/></option>
        <#if 'customform'=type>
        <#noparse><@cms.dictionaryDataList dictionaryId="</#noparse>${dictionaryId}<#noparse>">
            <#list list as d>
            <option value="${d.id.value}">${d.text}</option>
            </#list>
        </@cms.dictionaryDataList>
        </#noparse>
        <#else>
        <@cms.dictionaryDataList dictionaryId=dictionaryId>
            <#list list as d>
            <option value="${d.id.value}"${(value?has_content&&d.id.value=value)?then(' selected="true"','')?no_esc}>${d.text}</option>
            </#list>
        </@cms.dictionaryDataList>
        </#if>
        </select>
    </#if>
</#if>
</#macro>