Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FORMS-14814: allow multiple file attachment #191

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion blocks/form/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@
input.checked = field.value === input.value;
}
} else {
input.multiple = field.type === 'file[]';
input.multiple = field.type === 'file[]' || field.properties?.allowMultiple;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allow multiple check should not be required here. It should be handled via sling models.

}
if (field.required) {
input.setAttribute('required', 'required');
Expand All @@ -319,6 +319,9 @@
if (input.type === 'email') {
input.pattern = emailPattern;
}
if (input.multiple) {
field.type = 'file[]';
}
setConstraintsMessage(element, field.constraintMessages);
element.dataset.required = field.required;
}
Expand Down Expand Up @@ -510,7 +513,7 @@
}
return doc;
} catch (e) {
console.error('Unable to fetch form definition for path', pathname, path);

Check warning on line 516 in blocks/form/form.js

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
return null;
}
});
Expand Down
7 changes: 7 additions & 0 deletions component-models.json
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,13 @@
"name": "readOnly",
"label": "Read-only",
"valueType": "boolean"
},
{
"component": "boolean",
"name": "allowMultiple",
"label": "Allow multiple file attachments",
"valueType": "boolean",
"collapsible": false
}
]
},
Expand Down
7 changes: 7 additions & 0 deletions models/form/_file-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
"fields": [
{
"...": "./_common.json#/basicfields"
},
{
"component": "boolean",
"name": "allowMultiple",
"label": "Allow multiple file attachments",
"valueType": "boolean",
"collapsible": false
lovelymandal16 marked this conversation as resolved.
Show resolved Hide resolved
}
]
},
Expand Down
Loading