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'><div class="custom-control custom-checkbox"<#if params!=''> ${params}</#if>></#if>
26 <input type="checkbox" class="custom-control-input<#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> />
27 <label class="custom-control-label<#if orientation!='vertical'> checkbox-inline</#if><#if labelClass!=''> ${labelClass!}</#if>" for="${id}" <#if title!=''> title="${title}"</#if>>
28 <#if labelKey!=''>${labelKey}<#else><#nested></#if>
29 </label>
30 <#if orientation='vertical'></div></#if>
31 <#else>
32 <label class="form-check form-switch" for="${id}" <#if title!=''> title="${title}"</#if><#if params!=''> ${params}</#if>>
33 <input class="form-check-input<#if class!=''> ${class}</#if>" type="checkbox" id="${id}" name="${name}" value="<#if value!=''>${value}</#if>"<#if tabIndex!=''> tabindex="${tabIndex}"</#if><#if checked> checked</#if><#if disabled> disabled</#if><#if readonly> readonly</#if><#if params!=''> ${params}</#if><#if mandatory> required</#if>>
34 <span class="form-check-label<#if labelClass!=''> ${labelClass!}</#if>"><#if labelKey!=''>${labelKey}<#else><#nested></#if></span>
35 </label>
36 </#if>
37 </#macro>