1+ <#macro userProfileFormFields >
2+ <#assign currentGroup="" >
3+
4+ <#list profile.attributes as attribute >
5+
6+ <#if attribute.name=='locale' && realm.internationalizationEnabled && locale.currentLanguageTag?has_content >
7+ <input type =" hidden" id =" ${attribute.name}" name =" ${attribute.name}" value =" ${locale.currentLanguageTag}" />
8+ <#else >
9+
10+ <#assign group = (attribute.group)!"" >
11+ <#if group != currentGroup >
12+ <#assign currentGroup=group >
13+ <#if currentGroup != "" >
14+ <div class =" ${properties.kcFormGroupClass!}"
15+ <#list group.html5DataAnnotations as key, value >
16+ data-${key} ="${value} "
17+ </#list >
18+ >
19+
20+ <#assign groupDisplayHeader=group.displayHeader!"" >
21+ <#if groupDisplayHeader != "" >
22+ <#assign groupHeaderText=advancedMsg(groupDisplayHeader)!group >
23+ <#else >
24+ <#assign groupHeaderText=group.name!"" >
25+ </#if >
26+ <div class =" ${properties.kcContentWrapperClass!}" >
27+ <label id =" header-${attribute.group.name}" class =" ${kcFormGroupHeader!}" >${groupHeaderText} </label >
28+ </div >
29+
30+ <#assign groupDisplayDescription=group.displayDescription!"" >
31+ <#if groupDisplayDescription != "" >
32+ <#assign groupDescriptionText=advancedMsg(groupDisplayDescription)!"" >
33+ <div class =" ${properties.kcLabelWrapperClass!}" >
34+ <label id =" description-${group.name}" class =" ${properties.kcLabelClass!}" >${groupDescriptionText} </label >
35+ </div >
36+ </#if >
37+ </div >
38+ </#if >
39+ </#if >
40+
41+ <#nested "beforeField" attribute >
42+ <div class =" ${properties.kcFormGroupClass!}" >
43+ <div class =" ${properties.kcLabelWrapperClass!}" >
44+ <label for =" ${attribute.name}" class =" ${properties.kcLabelClass!}" >${advancedMsg(attribute.displayName!'') } </label >
45+ <#if attribute.required >*</#if >
46+ <#if attribute.name == "email" >${msg("registerAdditionaltext") } </#if >
47+ </div >
48+ <div class =" ${properties.kcInputWrapperClass!}" >
49+ <#if attribute.annotations.inputHelperTextBefore?? >
50+ <div class =" ${properties.kcInputHelperTextBeforeClass!}" id =" form-help-text-before-${attribute.name}" aria-live =" polite" >${kcSanitize(advancedMsg(attribute.annotations.inputHelperTextBefore))?no_esc } </div >
51+ </#if >
52+ <@inputFieldByType attribute=attribute/ >
53+ <#if messagesPerField.existsError('${attribute.name}') >
54+ <span id =" input-error-${attribute.name}" class =" ${properties.kcInputErrorMessageClass!}" aria-live =" polite" >
55+ ${kcSanitize(messagesPerField.get('${attribute.name } '))?no_esc}
56+ </span >
57+ </#if >
58+ <#if attribute.annotations.inputHelperTextAfter?? >
59+ <div class =" ${properties.kcInputHelperTextAfterClass!}" id =" form-help-text-after-${attribute.name}" aria-live =" polite" >${kcSanitize(advancedMsg(attribute.annotations.inputHelperTextAfter))?no_esc } </div >
60+ </#if >
61+ </div >
62+ </div >
63+ <#nested "afterField" attribute >
64+
65+ </#if >
66+ </#list >
67+
68+ <#list profile.html5DataAnnotations?keys as key >
69+ <script type =" module" src =" ${url.resourcesPath}/js/${key}.js" ></script >
70+ </#list >
71+ </#macro >
72+
73+ <#macro inputFieldByType attribute >
74+ <#switch attribute.annotations.inputType!'' >
75+ <#case 'textarea' >
76+ <@textareaTag attribute=attribute/ >
77+ <#break >
78+ <#case 'select' >
79+ <#case 'multiselect' >
80+ <@selectTag attribute=attribute/ >
81+ <#break >
82+ <#case 'select-radiobuttons' >
83+ <#case 'multiselect-checkboxes' >
84+ <@inputTagSelects attribute=attribute/ >
85+ <#break >
86+ <#default >
87+ <#if attribute.multivalued && attribute.values?has_content >
88+ <#list attribute.values as value >
89+ <@inputTag attribute=attribute value=value!''/ >
90+ </#list >
91+ <#else >
92+ <@inputTag attribute=attribute value=attribute.value!''/ >
93+ </#if >
94+ </#switch >
95+ </#macro >
96+
97+ <#macro inputTag attribute value >
98+ <input type =" <@inputTagType attribute=attribute/>" id =" ${attribute.name}" name =" ${attribute.name}" value =" ${(value!'')}" class =" ${properties.kcInputClass!}"
99+ aria-invalid =" <#if messagesPerField.existsError('${attribute.name}')>true</#if>"
100+ <#if attribute.readOnly >disabled</#if >
101+ <#if attribute.autocomplete?? >autocomplete="${attribute.autocomplete} "</#if >
102+ <#if attribute.annotations.inputTypePlaceholder?? >placeholder="${advancedMsg(attribute.annotations.inputTypePlaceholder)} "</#if >
103+ <#if attribute.annotations.inputTypePattern?? >pattern="${attribute.annotations.inputTypePattern} "</#if >
104+ <#if attribute.annotations.inputTypeSize?? >size="${attribute.annotations.inputTypeSize} "</#if >
105+ <#if attribute.annotations.inputTypeMaxlength?? >maxlength="${attribute.annotations.inputTypeMaxlength} "</#if >
106+ <#if attribute.annotations.inputTypeMinlength?? >minlength="${attribute.annotations.inputTypeMinlength} "</#if >
107+ <#if attribute.annotations.inputTypeMax?? >max="${attribute.annotations.inputTypeMax} "</#if >
108+ <#if attribute.annotations.inputTypeMin?? >min="${attribute.annotations.inputTypeMin} "</#if >
109+ <#if attribute.annotations.inputTypeStep?? >step="${attribute.annotations.inputTypeStep} "</#if >
110+ <#list attribute.html5DataAnnotations as key, value >
111+ data-${key} ="${value} "
112+ </#list >
113+ />
114+ </#macro >
115+
116+ <#macro inputTagType attribute >
117+ <#compress >
118+ <#if attribute.annotations.inputType?? >
119+ <#if attribute.annotations.inputType?starts_with("html5-") >
120+ ${attribute.annotations.inputType[6..] }
121+ <#else >
122+ ${attribute.annotations.inputType}
123+ </#if >
124+ <#else >
125+ text
126+ </#if >
127+ </#compress >
128+ </#macro >
129+
130+ <#macro textareaTag attribute >
131+ <textarea id =" ${attribute.name}" name =" ${attribute.name}" class =" ${properties.kcInputClass!}"
132+ aria-invalid =" <#if messagesPerField.existsError('${attribute.name}')>true</#if>"
133+ <#if attribute.readOnly >disabled</#if >
134+ <#if attribute.annotations.inputTypeCols?? >cols="${attribute.annotations.inputTypeCols} "</#if >
135+ <#if attribute.annotations.inputTypeRows?? >rows="${attribute.annotations.inputTypeRows} "</#if >
136+ <#if attribute.annotations.inputTypeMaxlength?? >maxlength="${attribute.annotations.inputTypeMaxlength} "</#if >
137+ >${(attribute.value!'') } </textarea >
138+ </#macro >
139+
140+ <#macro selectTag attribute >
141+ <select id =" ${attribute.name}" name =" ${attribute.name}" class =" ${properties.kcInputClass!}"
142+ aria-invalid =" <#if messagesPerField.existsError('${attribute.name}')>true</#if>"
143+ <#if attribute.readOnly >disabled</#if >
144+ <#if attribute.annotations.inputType=='multiselect' >multiple</#if >
145+ <#if attribute.annotations.inputTypeSize?? >size="${attribute.annotations.inputTypeSize} "</#if >
146+ >
147+ <#if attribute.annotations.inputType=='select' >
148+ <option value =" " ></option >
149+ </#if >
150+
151+ <#if attribute.annotations.inputOptionsFromValidation?? && attribute.validators[attribute.annotations.inputOptionsFromValidation ]?? && attribute.validators[attribute.annotations.inputOptionsFromValidation].options??>
152+ <#assign options=attribute.validators[attribute.annotations.inputOptionsFromValidation ].options>
153+ <#elseif attribute.validators.options?? && attribute.validators.options.options?? >
154+ <#assign options=attribute.validators.options.options >
155+ <#else >
156+ <#assign options=[ ]>
157+ </#if >
158+
159+ <#list options as option >
160+ <option value =" ${option}" <#if attribute.values?seq_contains(option) >selected</#if >><@selectOptionLabelText attribute=attribute option=option/ ></option >
161+ </#list >
162+
163+ </select >
164+ </#macro >
165+
166+ <#macro inputTagSelects attribute >
167+ <#if attribute.annotations.inputType=='select-radiobuttons' >
168+ <#assign inputType='radio' >
169+ <#assign classDiv=properties.kcInputClassRadio! >
170+ <#assign classInput=properties.kcInputClassRadioInput! >
171+ <#assign classLabel=properties.kcInputClassRadioLabel! >
172+ <#else >
173+ <#assign inputType='checkbox' >
174+ <#assign classDiv=properties.kcInputClassCheckbox! >
175+ <#assign classInput=properties.kcInputClassCheckboxInput! >
176+ <#assign classLabel=properties.kcInputClassCheckboxLabel! >
177+ </#if >
178+
179+ <#if attribute.annotations.inputOptionsFromValidation?? && attribute.validators[attribute.annotations.inputOptionsFromValidation ]?? && attribute.validators[attribute.annotations.inputOptionsFromValidation].options??>
180+ <#assign options=attribute.validators[attribute.annotations.inputOptionsFromValidation ].options>
181+ <#elseif attribute.validators.options?? && attribute.validators.options.options?? >
182+ <#assign options=attribute.validators.options.options >
183+ <#else >
184+ <#assign options=[ ]>
185+ </#if >
186+
187+ <#list options as option >
188+ <div class =" ${classDiv}" >
189+ <input type =" ${inputType}" id =" ${attribute.name}-${option}" name =" ${attribute.name}" value =" ${option}" class =" ${classInput}"
190+ aria-invalid =" <#if messagesPerField.existsError('${attribute.name}')>true</#if>"
191+ <#if attribute.readOnly >disabled</#if >
192+ <#if attribute.values?seq_contains(option) >checked</#if >
193+ />
194+ <label for =" ${attribute.name}-${option}" class =" ${classLabel}<#if attribute.readOnly> ${properties.kcInputClassRadioCheckboxLabelDisabled!}</#if>" ><@selectOptionLabelText attribute=attribute option=option/ ></label >
195+ </div >
196+ </#list >
197+ </#macro >
198+
199+ <#macro selectOptionLabelText attribute option >
200+ <#compress >
201+ <#if attribute.annotations.inputOptionLabels?? >
202+ ${advancedMsg(attribute.annotations.inputOptionLabels[option]!option) }
203+ <#else >
204+ <#if attribute.annotations.inputOptionLabelsI18nPrefix?? >
205+ ${msg(attribute.annotations.inputOptionLabelsI18nPrefix + '.' + option) }
206+ <#else >
207+ ${option}
208+ </#if >
209+ </#if >
210+ </#compress >
211+ </#macro >
0 commit comments