Skip to content

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

@migcosta

Description

@migcosta

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() ) ) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions