/
checkbox.html
43 lines (43 loc) · 1.7 KB
/
checkbox.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<th:block
th:fragment="checkbox"
th:with="
hasHelpText=${!#strings.isEmpty(checkboxHelpText)},
hasIcon=${!#strings.isEmpty(checkboxIcon)},
name=${inputName} + '[]',
hasError=${
errorMessages != null &&
errorMessages.get(inputName) != null &&
(#arrays.length(errorMessages.get(inputName)) > 0) }"
th:assert="
${!#strings.isEmpty(inputName)},
${!#strings.isEmpty(value)},
${!#strings.isEmpty(label)}">
<div th:class="'form-group' + ${(hasError ? ' form-group--error' : '')}">
<label th:for="${inputName} + '-' + ${value}"
th:id="${inputName} + '-' + ${value} + '-label'"
class="checkbox display-flex">
<input type="hidden" th:id="${inputName} + 'Hidden'" th:name="${name}" value="">
<input type="checkbox"
th:id="${inputName} + '-' + ${value}"
th:value="${value}"
th:name="${name}"
th:with="checked=${T(formflow.library.utils.InputUtils).arrayOrStringContains(fieldData.getOrDefault(name, ''), value)}"
th:checked="${checked}"
th:attr="
aria-invalid=${hasError},
data-follow-up=${followUpId}">
<div th:if="${hasIcon}">
<i th:class="${'icon-' + checkboxIcon}" style="margin-right: 0.5rem"></i>
</div>
<div>
<span th:text="${label}"></span>
<p th:if="${hasHelpText}"
th:id="${name} + '-' + ${value} + '-help-text'"
th:text="${checkboxHelpText}"
class="text--help with-no-padding"></p>
</div>
</label>
<th:block
th:replace="~{fragments/inputError :: validationError(inputName=${inputName})}"></th:block>
</div>
</th:block>