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

Builder hasFile() Fails to Recognize Custom File Upload Fields #200

Open
migcosta opened this issue Dec 23, 2024 · 0 comments
Open

Builder hasFile() Fails to Recognize Custom File Upload Fields #200

migcosta opened this issue Dec 23, 2024 · 0 comments

Comments

@migcosta
Copy link

https://github.com/open-admin-org/open-admin/blob/dc6206d9f7ce3b59a80994828dea540460108791/src/Form/Builder.php#L452C13-L452C86

Description
The hasFile() function is designed to determine if a form includes file fields and applies the necessary enctype="multipart/form-data" attribute. However, it only checks for fields that are instances of Field\File or Field\MultipleFile.

I have implemented a custom file uploader with cropping functionality. Since my custom fields do not extend from either of the expected classes (Field\File or Field\MultipleFile), the hasFile() function fails to recognize them as file upload fields. Consequently, the form does not receive the correct enctype attribute, causing the file uploads to fail.

Proposed Solution
Allow hasFile() to be extensible or configurable so that it can detect custom file fields. Example:
if ( $field instanceof Field\File || $field instanceof Field\MultipleFile || ( method_exists($field, 'isFileField') && $field->isFileField() ) ) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant