forked from neos/form-fusionrenderer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FormElement.fusion
87 lines (76 loc) · 3.33 KB
/
FormElement.fusion
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
prototype(Neos.Form.FusionRenderer:FormElement) < prototype(Neos.Fusion:Array) {
@context.elementName = ${'--' + formRuntime.identifier + '[' + element.identifier + ']'}
@context.elementValue = ${Neos.Form.elementValue(formRuntime, element)}
@context.elementValidationErrors = ${Neos.Form.validationErrors(formRuntime, element)}
@context.elementHasValidationErrors = ${Neos.Form.hasValidationErrors(formRuntime, element)}
label = Neos.Form.FusionRenderer:FormElementLabel
fieldContainer = Neos.Form.FusionRenderer:FormElementFieldContainer
@process.wrap = Neos.Fusion:Tag {
tagName = 'div'
attributes.class = ${hasValidationErrors ? 'clearfix error' : 'clearfix'}
content = ${value}
}
@process.renderCallbacks = Neos.Form.FusionRenderer:RenderCallbacks {
@position = 'end'
formRuntime = ${formRuntime}
formElement = ${element}
}
}
prototype(Neos.Form.FusionRenderer:FormElementLabel) < prototype(Neos.Fusion:Tag) {
tagName = 'label'
attributes {
for = ${element.uniqueIdentifier}
}
content = Neos.Fusion:Array {
value = ${Neos.Form.translateAndEscapeProperty(element, 'label')}
requiredFlag = Neos.Form.FusionRenderer:RequiredFlag
[email protected] = ${element.required}
}
}
prototype(Neos.Form.FusionRenderer:RequiredFlag) < prototype(Neos.Fusion:Tag) {
tagName = 'span'
attributes.class = 'required'
content = '*'
}
prototype(Neos.Form.FusionRenderer:FormElementFieldContainer) < prototype(Neos.Fusion:Array) {
field = Neos.Form.FusionRenderer:FormElementField
validationErrors = Neos.Form.FusionRenderer:FormElementValidationErrors
elementDescription = Neos.Form.FusionRenderer:FormElementDescription
@process.wrap = Neos.Fusion:Tag {
tagName = 'div'
attributes.class = ${element.properties.containerClassAttribute}
content = ${value}
}
}
prototype(Neos.Form.FusionRenderer:FormElementField) < prototype(Neos.Fusion:Tag) {
attributes {
placeholder = ${element.properties.placeholder}
class = Neos.Fusion:Array {
defaultClass = ${element.properties.elementClassAttribute ? element.properties.elementClassAttribute : null}
errorClass = ${element.properties.elementErrorClassAttribute ? element.properties.elementErrorClassAttribute : 'error'}
[email protected] = ${' ' + value}
[email protected] = ${elementHasValidationErrors}
}
id = ${element.uniqueIdentifier}
}
}
prototype(Neos.Form.FusionRenderer:FormElementValidationErrors) < prototype(Neos.Fusion:Tag) {
tagName = 'span'
attributes {
class = 'help-inline'
}
content = Neos.Fusion:Collection {
collection = ${elementValidationErrors}
itemName = 'error'
itemRenderer = ${Translation.translate(error.code, null, error.arguments, 'ValidationErrors', element.renderingOptions.validationErrorTranslationPackage)}
}
@if.hasValidationErrors = ${elementHasValidationErrors}
}
prototype(Neos.Form.FusionRenderer:FormElementDescription) < prototype(Neos.Fusion:Tag) {
tagName = 'span'
attributes {
class = 'help-block'
}
content = ${element.properties.elementDescription}
@if.condition = ${element.properties.elementDescription ? true : false}
}