Skip to content

Commit e4a040e

Browse files
Forms-20262: FileInput v4 (#1618)
* FORMS-20262: Handle invalid file attachments on client-side * add functionality to get collated alert message with multiple invalid errors * FORMS-20262: Update alert message content * FORMS-20262: Update alert message content * FORMS-20262: revert the fileinput base class to clean state * FORMS-20262: add size zero file error in error list * FORMS-20262: create fileinput v4 * checks for file size of 0 and throws error * collates all error messages in single alert * FORMS-20262: Update file input v4 readme * FORMS-20262: Update component version to v4 in readme * FORMS-20262: test cases for fileinput v4 * add collateral * create page for fileinput v4 * FORMS-20262: Update copyright year * FORMS-20262: fix resource super type * FORMS-20262: fix tracking feature for file input * FORMS-20262: add error message for zero-bytes file in all locale * FORMS-20262: mark head text as isHeading * FORMS-20262: pom replace fileinput v4 in libs
1 parent 7cad1ee commit e4a040e

File tree

30 files changed

+1029
-4
lines changed

30 files changed

+1029
-4
lines changed

examples/ui.apps/src/main/content/jcr_root/apps/forms-components-examples/components/form/fileinput/.content.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
jcr:primaryType="cq:Component"
44
jcr:title="Adaptive Form File Attachment"
55
jcr:description="Add a button to upload one or more files as form attachment."
6-
sling:resourceSuperType="core/fd/components/form/fileinput/v3/fileinput"
6+
sling:resourceSuperType="core/fd/components/form/fileinput/v4/fileinput"
77
componentGroup="Core Components Examples - Adaptive Form"/>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
~ Copyright 2025 Adobe
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
17+
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
18+
jcr:description="Page Component for the Core Components IT"
19+
jcr:primaryType="cq:Component"
20+
jcr:title="Page"
21+
sling:resourceSuperType="forms-components-examples/components/page"
22+
componentGroup=".hidden"/>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2+
~ Copyright 2025 Adobe
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" BASIS,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
16+
<sly data-sly-use.clientlib="core/wcm/components/commons/v1/templates/clientlib.html"
17+
data-sly-use.formclientlibmanager="com.adobe.cq.forms.core.components.models.form.FormClientLibManager">
18+
<sly data-sly-repeat="${formclientlibmanager.clientLibRefList}" data-sly-call="${clientlib.js @ categories=item, async=true}"/>
19+
</sly>
20+
<!-- Adding core.forms.components.it.runtime.all as we need to embed all component client libraries inside all due to inter dependency between them -->
21+
<!-- core.forms.components.it.textinput.v1.runtime is embedded as part of core.forms.components.it.runtime.all -->
22+
<sly data-sly-use.clientlib="core/wcm/components/commons/v1/templates/clientlib.html">
23+
<sly data-sly-test="${!wcmmode.edit}" data-sly-call="${clientlib.js @ categories=['core.forms.components.runtime.base','core.forms.components.container.v2.runtime','core.forms.components.fileinput.v4.runtime','core.forms.components.button.v1.runtime'], async=false}"/>
24+
</sly>
25+
<sly data-sly-use.page="com.adobe.cq.wcm.core.components.models.Page">
26+
<sly data-sly-test="${page.data && page.dataLayerClientlibIncluded}" data-sly-call="${clientlib.js @ categories='core.forms.components.commons.v1.datalayer', async=true}"></sly>
27+
</sly>
28+
29+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:rep="internal"
3+
jcr:mixinTypes="[rep:AccessControllable]"
4+
jcr:primaryType="sling:Folder"
5+
hidden="true"/>
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:fd="http://www.adobe.com/aemfd/fd/1.0"
3+
jcr:primaryType="cq:Page">
4+
<jcr:content
5+
cq:deviceGroups="[mobile/groups/responsive]"
6+
cq:lastModified="{Date}2023-01-25T17:24:29.344+05:30"
7+
cq:lastModifiedBy="admin"
8+
cq:template="/conf/core-components-examples/settings/wcm/templates/af-blank-v2"
9+
jcr:language="en"
10+
jcr:primaryType="cq:PageContent"
11+
jcr:title="Adaptive Form V4 (IT)"
12+
sling:configRef="/conf/forms/core-components-it/samples/fileinput/fileinputv4/basic/"
13+
sling:resourceType="forms-core-components-it/components/page-fileinputv4">
14+
<guideContainer
15+
fd:version="2.1"
16+
jcr:lastModified="{Date}2023-01-17T16:29:57.778+05:30"
17+
jcr:lastModifiedBy="admin"
18+
jcr:primaryType="nt:unstructured"
19+
sling:resourceType="forms-components-examples/components/form/container"
20+
actionType="forms-core-components-it/customsubmission/logsubmit"
21+
dorType="none"
22+
fieldType="form"
23+
prefillService="Core Custom Pre-fill Service"
24+
textIsRich="true"
25+
thankYouMessage="Thank you for submitting the form."
26+
thankYouOption="page">
27+
<fileinput1
28+
jcr:lastModified="{Date}2023-01-24T16:47:36.882+05:30"
29+
jcr:lastModifiedBy="admin"
30+
jcr:primaryType="nt:unstructured"
31+
jcr:title="File Input - 1"
32+
sling:resourceType="core/fd/components/form/fileinput/v3/fileinput"
33+
accept="[audio/*, video/*, image/*, text/*, application/pdf]"
34+
buttonText="Attach Files"
35+
enabled="{Boolean}true"
36+
fieldType="file-input"
37+
multiSelection="true"
38+
name="fileinput1"
39+
readOnly="{Boolean}false"
40+
textIsRich="[true,true]"
41+
type="file[]"
42+
visible="{Boolean}true"/>
43+
<fileinput2
44+
jcr:primaryType="nt:unstructured"
45+
jcr:title="File Input - 2"
46+
sling:resourceType="core/fd/components/form/fileinput/v3/fileinput"
47+
accept="[audio/*, video/*, image/*, text/*, application/pdf]"
48+
fieldType="file-input"
49+
name="fileinput2"
50+
type="file"/>
51+
<fileinput3
52+
jcr:primaryType="nt:unstructured"
53+
jcr:title="File Input - 3"
54+
sling:resourceType="core/fd/components/form/fileinput/v3/fileinput"
55+
accept="[application/pdf]"
56+
description="This is long description"
57+
fieldType="file-input"
58+
id="fileinput_tooltip_scenario_test"
59+
name="fileinput3"
60+
tooltip="This is short description"
61+
tooltipVisible="true"
62+
type="file"/>
63+
<fileinput4
64+
jcr:primaryType="nt:unstructured"
65+
jcr:title="File Input - 4"
66+
sling:resourceType="core/fd/components/form/fileinput/v3/fileinput"
67+
accept="[application/x-msdownload,application/vnd.ms-outlook,application/pdf]"
68+
description="This is long description"
69+
fieldType="file-input"
70+
id="fileinput_unknown_mimetype_test"
71+
name="fileinput4"
72+
tooltip="This is short description"
73+
multiSelection="true"
74+
type="file"/>
75+
<fileinput5
76+
jcr:lastModified="{Date}2023-01-24T16:47:36.882+05:30"
77+
jcr:lastModifiedBy="admin"
78+
jcr:primaryType="nt:unstructured"
79+
jcr:title="File Input - 5"
80+
sling:resourceType="core/fd/components/form/fileinput/v3/fileinput"
81+
accept="[audio/*, video/*, image/*, text/*, application/pdf]"
82+
buttonText="Attach Files"
83+
enabled="{Boolean}true"
84+
fieldType="file-input"
85+
name="fileinput5"
86+
readOnly="{Boolean}true"
87+
textIsRich="[true,true]"
88+
maxFileSize="2"
89+
type="file[]"
90+
visible="{Boolean}true"/>
91+
<fileinput6
92+
jcr:primaryType="nt:unstructured"
93+
jcr:title="File Input - 6"
94+
sling:resourceType="core/fd/components/form/fileinput/v3/fileinput"
95+
accept="[audio/*, video/*, image/*, text/*, application/pdf]"
96+
buttonText="Attach Files"
97+
enabled="{Boolean}true"
98+
maxFileSizeMessage="File size is greater than the expected size!"
99+
fieldType="file-input"
100+
name="fileinput6"
101+
readOnly="{Boolean}true"
102+
textIsRich="[true,true]"
103+
maxFileSize="2"
104+
type="file[]"
105+
visible="{Boolean}true"/>
106+
<submit
107+
jcr:lastModified="{Date}2023-01-17T16:28:58.844+05:30"
108+
jcr:lastModifiedBy="admin"
109+
jcr:primaryType="nt:unstructured"
110+
jcr:title="Submit"
111+
sling:resourceType="forms-components-examples/components/form/actions/submit"
112+
buttonType="submit"
113+
dorExclusion="true"
114+
fieldType="button"
115+
name="submit1673953138924">
116+
<fd:rules
117+
fd:click="[{&quot;nodeName&quot;:&quot;ROOT&quot;\,&quot;items&quot;:[{&quot;nodeName&quot;:&quot;STATEMENT&quot;\,&quot;choice&quot;:{&quot;nodeName&quot;:&quot;EVENT_SCRIPTS&quot;\,&quot;items&quot;:[{&quot;nodeName&quot;:&quot;EVENT_CONDITION&quot;\,&quot;choice&quot;:{&quot;nodeName&quot;:&quot;EVENT_AND_COMPARISON&quot;\,&quot;items&quot;:[{&quot;nodeName&quot;:&quot;COMPONENT&quot;\,&quot;value&quot;:{&quot;id&quot;:&quot;$form.button1667450213112&quot;\,&quot;type&quot;:&quot;BUTTON&quot;\,&quot;name&quot;:&quot;button1667450213112&quot;}}\,{&quot;nodeName&quot;:&quot;EVENT_AND_COMPARISON_OPERATOR&quot;\,&quot;choice&quot;:{&quot;nodeName&quot;:&quot;is clicked&quot;\,&quot;value&quot;:null}}\,{&quot;nodeName&quot;:&quot;PRIMITIVE_EXPRESSION&quot;\,&quot;choice&quot;:null}]}\,&quot;nested&quot;:false}\,{&quot;nodeName&quot;:&quot;Then&quot;\,&quot;value&quot;:null}\,{&quot;nodeName&quot;:&quot;BLOCK_STATEMENTS&quot;\,&quot;items&quot;:[{&quot;nodeName&quot;:&quot;BLOCK_STATEMENT&quot;\,&quot;choice&quot;:{&quot;nodeName&quot;:&quot;SUBMIT_FORM&quot;\,&quot;items&quot;:[]}}]}]}}]\,&quot;isValid&quot;:true\,&quot;enabled&quot;:true\,&quot;version&quot;:1\,&quot;script&quot;:[&quot;submitForm()&quot;]\,&quot;eventName&quot;:&quot;Click&quot;\,&quot;ruleType&quot;:&quot;&quot;\,&quot;description&quot;:&quot;&quot;}]"
118+
jcr:primaryType="nt:unstructured"/>
119+
<fd:events
120+
jcr:primaryType="nt:unstructured"
121+
click="[submitForm()]"/>
122+
</submit>
123+
</guideContainer>
124+
</jcr:content>
125+
</jcr:root>

ui.af.apps/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@
339339
<replace file="target/jcr_root/libs/core/fd/components/form/review/v1/.content.xml" token=".core-adaptiveform" value="Core Adaptive Form" />
340340
<replace file="target/jcr_root/libs/core/fd/components/form/toggleablelink/v1/toggleablelink/.content.xml" token=".core-adaptiveform" value="Core Adaptive Form" />
341341
<replace file="target/jcr_root/libs/core/fd/components/form/turnstile/v1/turnstile/.content.xml" token=".core-adaptiveform" value="Core Adaptive Form" />
342+
<replace file="target/jcr_root/libs/core/fd/components/form/fileinput/v4/fileinput/.content.xml" token=".core-adaptiveform" value="Core Adaptive Form" />
342343
</target>
343344
</configuration>
344345
<goals>

ui.af.apps/src/main/content/jcr_root/apps/core/fd/af-clientlibs/core-forms-components-runtime-all/.content.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
cssProcessor="[default:none,min:none]"
66
jsProcessor="[default:none,min:none]"
77
categories="[core.forms.components.runtime.all]"
8-
embed="[core.forms.components.runtime.base,core.forms.components.container.v2.runtime,core.forms.components.datePicker.v1.runtime,core.forms.components.textinput.v1.runtime,core.forms.components.numberinput.v1.runtime,core.forms.components.panelcontainer.v1.runtime,core.forms.components.radiobutton.v1.runtime,core.forms.components.text.v1.runtime,core.forms.components.checkboxgroup.v1.runtime,core.forms.components.button.v1.runtime,core.forms.components.image.v1.runtime,core.forms.components.dropdown.v1.runtime,core.forms.components.fileinput.v3.runtime,core.forms.components.accordion.v1.runtime,core.forms.components.tabs.v1.runtime,core.forms.components.wizard.v1.runtime,core.forms.components.verticaltabs.v1.runtime,core.forms.components.recaptcha.v1.runtime,core.forms.components.checkbox.v1.runtime,core.forms.components.fragment.v1.runtime,core.forms.components.switch.v1.runtime,core.forms.components.termsandconditions.v1.runtime, core.forms.components.hcaptcha.v1.runtime,core.forms.components.review.v1.runtime, core.forms.components.turnstile.v1.runtime]"/>
8+
embed="[core.forms.components.runtime.base,core.forms.components.container.v2.runtime,core.forms.components.datePicker.v1.runtime,core.forms.components.textinput.v1.runtime,core.forms.components.numberinput.v1.runtime,core.forms.components.panelcontainer.v1.runtime,core.forms.components.radiobutton.v1.runtime,core.forms.components.text.v1.runtime,core.forms.components.checkboxgroup.v1.runtime,core.forms.components.button.v1.runtime,core.forms.components.image.v1.runtime,core.forms.components.dropdown.v1.runtime,core.forms.components.fileinput.v4.runtime,core.forms.components.accordion.v1.runtime,core.forms.components.tabs.v1.runtime,core.forms.components.wizard.v1.runtime,core.forms.components.verticaltabs.v1.runtime,core.forms.components.recaptcha.v1.runtime,core.forms.components.checkbox.v1.runtime,core.forms.components.fragment.v1.runtime,core.forms.components.switch.v1.runtime,core.forms.components.termsandconditions.v1.runtime, core.forms.components.hcaptcha.v1.runtime,core.forms.components.review.v1.runtime, core.forms.components.turnstile.v1.runtime]"/>

ui.af.apps/src/main/content/jcr_root/apps/core/fd/af-clientlibs/core-forms-components-runtime-all/resources/i18n/de.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"FileNameInvalid": "Hängen Sie keine Dateien an, deren Dateiname mit (.) beginnt, \\ / : * ? \" < > | ; % oder $ enthält oder ein reserviertes Schlüsselwort wie nul, prn, con, lpt oder com ist.",
55
"FileMimeTypeInvalid": "Datei(en) ${0} ist/sind nicht unterstützte(r) Dateityp(en)",
66
"InternalFormSubmissionError": "Beim Übermitteln des Formulars ist ein interner Fehler aufgetreten.",
7+
"FileSizeZero": "Die hochgeladenen Dateien ${0} sind leer. Stellen Sie sicher, dass Sie Dateien mit Inhalt hochladen.",
78
"type": "Bitte geben Sie einen gültigen Wert ein.",
89
"required": "Bitte füllen Sie dieses Feld aus.",
910
"minimum": "Der Wert muss größer als oder gleich ${0} sein.",

ui.af.apps/src/main/content/jcr_root/apps/core/fd/af-clientlibs/core-forms-components-runtime-all/resources/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"FileNameInvalid" : "Do not attach files where filename starts with (.), contains \\ / : * ? \" < > | ; % $, or is a reserved keyword like nul, prn, con, lpt, or com.",
55
"FileMimeTypeInvalid" : "File(s) ${0} are unsupported file types",
66
"InternalFormSubmissionError" : "Encountered an internal error while submitting the form.",
7+
"FileSizeZero" : "The uploaded file(s) ${0} are empty. Make sure you're uploading file(s) with content.",
78
"type" : "Please enter a valid value.",
89
"required" : "Please fill in this field.",
910
"minimum" : "Value must be greater than or equal to ${0}.",

ui.af.apps/src/main/content/jcr_root/apps/core/fd/af-clientlibs/core-forms-components-runtime-all/resources/i18n/es.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"FileNameInvalid": "No adjunte archivos cuyo nombre comience con (.), contenga \\ / : * ? \" < > | ; % $, o sea una palabra clave reservada como nul, prn, con, lpt o com.",
55
"FileMimeTypeInvalid": "Los tipos de archivo ${0} no son compatibles",
66
"InternalFormSubmissionError": "Error interno al enviar el formulario.",
7+
"FileSizeZero": "Los archivos subidos ${0} están vacíos. Asegúrate de que estén subiendo archivos con contenido",
78
"type": "Introduzca un valor válido.",
89
"required": "Rellene este campo.",
910
"minimum": "El valor debe ser mayor que o igual a ${0}.",

0 commit comments

Comments
 (0)