Open Schuppel1 opened 2 months ago
In this PR the FileUpload FormElement getting a validators
form-builder/Configuration/NodeTypes.FormElements.FileUpload.yaml
'allowedExtensions': type: array ui: label: i18n reloadIfChanged: true inspector: group: 'formElement' editor: 'Neos.Neos/Inspector/Editors/SelectBoxEditor' editorOptions: values: 'pdf': label: '.pdf' icon: 'icon-file-pdf-o' 'xls': label: '.xls' icon: 'icon-file-excel-o' 'xlsx': label: '.xlsx' icon: 'icon-file-excel-o' 'doc': label: '.doc' icon: 'icon-file-text' 'docx': label: '.docx' icon: 'icon-file-text' 'odt': label: '.odt' icon: 'icon-file-text' 'csv': label: '.csv' icon: 'icon-file-text'
The code above is removed from FileUpload and become an validator Configuration/NodeTypes.Validator.FileExtension.yaml
FileUpload
Configuration/NodeTypes.Validator.FileExtension.yaml
'Neos.Form.Builder:FileExtensionValidator': superTypes: 'Neos.Form.Builder:AbstractValidator': true ui: label: 'File-Extension Validator' icon: 'icon-file-archive' inspector: groups: 'validator': icon: 'icon-filter' properties: 'allowedExtensions': type: array ui: label: i18n reloadIfChanged: true inspector: group: 'validator' editor: 'Neos.Neos/Inspector/Editors/SelectBoxEditor' editorOptions: values: 'pdf': label: '.pdf' icon: 'icon-file-pdf-o' 'xls': label: '.xls' icon: 'icon-file-excel-o' 'xlsx': label: '.xlsx' icon: 'icon-file-excel-o' 'doc': label: '.doc' icon: 'icon-file-text' 'docx': label: '.docx' icon: 'icon-file-text' 'odt': label: '.odt' icon: 'icon-file-text' 'csv': label: '.csv' icon: 'icon-file-text' 'zip': label: '.zip' icon: 'icon-file-text'
Another Validator is the FileSizeValidator
FileSizeValidator
'Neos.Form.Builder:FileSizeValidator': superTypes: 'Neos.Form.Builder:AbstractValidator': true ui: label: 'File-Size range Validator' icon: 'icon-arrows-alt-h' inspector: groups: 'validator': icon: 'icon-sort-numeric-asc' properties: 'minimum': type: integer defaultValue: 0 ui: label: i18n inspector: group: 'validator' 'maximum': type: integer defaultValue: 100 ui: label: i18n inspector: group: 'validator'
A Mixin: FileValidatorsMixin
FileValidatorsMixin
'Neos.Form.Builder:FileValidatorsMixin': abstract: true superTypes: 'Neos.Form.Builder:ValidatorsMixin': true childNodes: 'validators': constraints: nodeTypes: 'Neos.Form.Builder:FileSizeValidator': true 'Neos.Form.Builder:FileExtensionValidator': true
Now inside of NEOS it looks like this:
Dependencies with another Package! Neos:Form Neos.Form/Configuration/Settings.yaml
Neos:Form
Neos.Form/Configuration/Settings.yaml
It is needed to add the following:
'Neos.Flow:FileSize': implementationClassName: Neos\Flow\Validation\Validator\FileSizeValidator 'Neos.Flow:FileExtension': implementationClassName: Neos\Flow\Validation\Validator\FileExtensionValidator
to:
Neos: Form: presets: default: validatorPresets:
Neos:Form Neos.Form/Classes/FormElements/FileUpload.php Remove old FileExtensionValidation Code
Neos.Form/Classes/FormElements/FileUpload.php
$fileTypeValidator = new FileTypeValidator(array('allowedExtensions' => $this->properties['allowedExtensions'])); $this->addValidator($fileTypeValidator);
This can be removed.
We need a migration: for smooth use. I'm not good with migrations.
In this PR the FileUpload FormElement getting a validators
form-builder/Configuration/NodeTypes.FormElements.FileUpload.yaml
The code above is removed from
FileUpload
and become an validatorConfiguration/NodeTypes.Validator.FileExtension.yaml
Another Validator is the
FileSizeValidator
A Mixin:
FileValidatorsMixin
Now inside of NEOS it looks like this:
Important:
Dependencies with another Package!
Neos:Form
Neos.Form/Configuration/Settings.yaml
It is needed to add the following:
to:
Neos:Form
Neos.Form/Classes/FormElements/FileUpload.php
Remove old FileExtensionValidation CodeThis can be removed.
Problem:
We need a migration: for smooth use. I'm not good with migrations.