formLabel.ftl

 1   <#-- Macro: formLabel
 2   
 3   Description: Generates a label for a Bootstrap form group.
 4   
 5   Parameters:
 6   - class (string, optional): additional CSS classes to add to the label element.
 7   - labelFor (string, optional): the ID of the input field that the label is associated with.
 8   - labelId (string, optional): the ID of the label element.
 9   - labelKey (string, optional): the internationalization key for the label text.
 10   - hideLabel (list, optional): a list of label properties to hide (e.g. "label", "i18nLabel").
 11   - mandatory (boolean, optional): whether the input field is mandatory.
 12   - deprecated: whether the macro is deprecated.
 13   
 14   -->
 15   <#macro formLabel class='' labelFor='' labelId='' labelKey='' labelKeyDesc='' hideLabel=[] mandatory=true deprecated...>
 16       <@deprecatedWarning args=deprecated />
 17       <#local labelClass = ' ' + displaySettings( hideLabel, '' ) />
 18       <label class="form-label<#if mandatory=true> required</#if><#if class !=''> ${class?trim}<#else> w-100</#if><#if hideLabel?seq_contains('all')> visually-hidden</#if> " for="${labelFor}" <#if labelId!=''> id="${labelId}"</#if>>
 19           <#if labelKey?trim !=''>
 20               <#if labelClass?trim !=''>
 21                   <span class="${labelClass}">
 22               </#if>
 23               ${labelKey!?trim}
 24               <#if mandatory=true>
 25                   <span class="text-danger fw-bolder"><i class="ti ti-asterisk"></i></span>
 26               </#if>
 27               <#if labelClass?trim !=''>
 28                   </span>
 29               </#if>
 30               <#if labelKeyDesc?trim !=''>
 31                   <div class="form-label-description float-end">${labelKeyDesc} <span class="text-danger float-end fw-bolder"><i class="ti ti-asterisk"></i></span></div>
 32               </#if>
 33           <#else>
 34               <#nested>
 35           </#if>
 36       </label>
 37   </#macro>