radioButton.ftl
1 <#--
2 Macro: radioButton
3
4 Description: Generates an HTML radio button element with a specified name, ID, label, orientation, value, tabindex, title, disabled, readonly, checked, parameters, and mandatory flag.
5
6 Parameters:
7 - name (string, required): the name for the radio button element.
8 - id (string, optional): the ID for the radio button element.
9 - labelKey (string, optional): the label for the radio button element.
10 - labelFor (string, optional): the "for" attribute for the radio button's label element.
11 - orientation (string, optional): the orientation for the radio button element, either "vertical" (default) or "inline".
12 - value (string, optional): the value for the radio button element.
13 - tabIndex (string, optional): the tabindex for the radio button element.
14 - title (string, optional): the title for the radio button element.
15 - disabled (boolean, optional): whether the radio button element is disabled.
16 - readonly (boolean, optional): whether the radio button element is readonly.
17 - checked (boolean, optional): whether the radio button element is checked.
18 - params (string, optional): additional parameters to add to the HTML code.
19 - mandatory (boolean, optional): whether the radio button element is mandatory.
20 - propagateMandatory (boolean, optional): whether to propagate the mandatory flag to the radio button element.
21 -->
22 <#macro radioButton name id='' class='form-check-input' labelKey='' labelClass='' labelFor='' orientation='vertical' value='' tabIndex='' title='' disabled=false readonly=false checked=false params='' mandatory=false >
23 <#if propagateMandatory?? && propagateMandatory ><#local mandatory = true /></#if>
24 <#if orientation='vertical'><div class="radio"<#if params!=''> ${params}</#if>> </#if>
25 <label class="form-check<#if orientation!='vertical'> form-check-inline</#if><#if labelClass!=''> ${labelClass!}</#if>"<#if labelFor!=''> for="${labelFor}"</#if>>
26 <input class="<#if class!=''> ${class}</#if>" type="radio" 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!='' && orientation !='vertical'> ${params}</#if><#if mandatory> required</#if>>
27 <#if labelKey!=''>
28 <span class="form-check-label<#if labelClass!=''> ${labelClass!}</#if>"><#if labelKey!=''>${labelKey}<#else><#nested></#if></span>
29 </#if>
30 <#nested>
31 </label>
32 <#if orientation='vertical'></div></#if>
33 </#macro>