checkBox.ftl
1 <#--
2 Macro: checkBox
3
4 Description: Generates an HTML checkbox element with a specified ID, name, class, label, orientation, value, tabindex, title, disabled, readonly, checked, parameters, and mandatory flag.
5
6 Parameters:
7 - name (string, required): the name for the checkbox element.
8 - id (string, optional): the ID for the checkbox element.
9 - class (string, optional): additional classes to add to the checkbox element.
10 - labelKey (string, optional): the label for the checkbox element.
11 - orientation (string, optional): the orientation for the checkbox element, either "vertical" (default) or "switch".
12 - value (string, optional): the value for the checkbox element.
13 - tabIndex (string, optional): the tabindex for the checkbox element.
14 - title (string, optional): the title for the checkbox element.
15 - disabled (boolean, optional): whether the checkbox element is disabled.
16 - readonly (boolean, optional): whether the checkbox element is readonly.
17 - checked (boolean, optional): whether the checkbox element is checked.
18 - params (string, optional): additional parameters to add to the HTML code.
19 - mandatory (boolean, optional): whether the checkbox element is mandatory.
20 -->
21 <#macro checkBox name id='' class='' labelKey='' labelClass='' orientation='vertical' value='' tabIndex='' title='' disabled=false readonly=false checked=false params='' mandatory=false deprecated...>
22 <@deprecatedWarning args=deprecated />
23 <#if id = ''><#local id = name /></#if>
24 <#if orientation!='switch'>
25 <#if orientation='vertical'>
26 <div class="form-check"<#if params!=''> ${params}</#if>>
27 <#else>
28 <div class="form-check form-check-inline"<#if params!=''> ${params}</#if>>
29 </#if>
30 <input type="checkbox" class="form-check-input me-1<#if class!=''> ${class}</#if>" id="${id}" name="${name}"<#if value!=''> value="${value}"</#if><#if tabIndex!=''> tabindex="${tabIndex}"</#if><#if checked> checked</#if><#if disabled> disabled</#if><#if readonly> readonly</#if><#if mandatory> required</#if> />
31 <label class="form-check-label<#if labelClass!=''> ${labelClass!}</#if>" for="${id}" <#if title!=''> title="${title}"</#if>>
32 <#if labelKey!=''>${labelKey}<#else><#nested></#if>
33 </label>
34 </div>
35 <#else>
36 <div class="form-switch">
37 <input class="form-check-input<#if class!=''> ${class}</#if>" type="checkbox" id="${id}" name="${name}"<#if value!=''> value="${value}"</#if><#if tabIndex!=''> tabindex="${tabIndex}"</#if><#if checked> checked</#if><#if disabled> disabled</#if><#if readonly> readonly</#if><#if mandatory> required</#if><#if params!=''> ${params}</#if> />
38 <label class="form-check-label<#if labelClass!=''> ${labelClass!}</#if>" for="${id}">
39 <#if labelKey!=''>${labelKey}<#else><#nested></#if>
40 </label>
41 </div>
42 </#if>
43 </#macro>