Skip to content

Commit

Permalink
add limit size boolean option
Browse files Browse the repository at this point in the history
  • Loading branch information
haroun committed Oct 9, 2023
1 parent 4238028 commit 4abb057
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"fieldRequired": "Is this field required?",
"file": "File attachment",
"fileAllowMultiple": "Allow multiple file attachments",
"fileLimitSize": "Limit file size?",
"fileMaxSize": "Max file attachment size",
"fileMaxSizeError": "File is too large '%1$s' (max size: %2$s).",
"fileMaxSizeHelp": "In Bytes",
Expand Down
10 changes: 9 additions & 1 deletion modules/@apostrophecms/form-file-field-widget/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@ module.exports = {
type: 'boolean',
def: true
},
limitSize: {
label: 'aposForm:fileLimitSize',
type: 'boolean',
def: false
},
maxSize: {
label: 'aposForm:fileMaxSize',
help: 'aposForm:fileMaxSizeHelp',
type: 'integer'
type: 'integer',
if: {
limitSize: true
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class="apos-form-input {{ prependIfPrefix('__input') }}"
type="file" id="{{ id }}"
{% if widget.allowMultiple %}multiple{% endif %}
{% if widget.maxSize %}
{% if widget.limitSize and widget.maxSize %}
data-max-size="{{ widget.maxSize }}"
data-max-size-error="{{ __t('aposForm:fileMaxSizeError') }}"
data-file-size-units="{{ widget.fileSizeUnits | jsonAttribute }}"
Expand Down

0 comments on commit 4abb057

Please sign in to comment.