Skip to content

Comments

Add FileField for Files.#6587

Closed
bytes-max wants to merge 1 commit intoEasyCorp:4.xfrom
bytes-max:bytes-commerce-file-field
Closed

Add FileField for Files.#6587
bytes-max wants to merge 1 commit intoEasyCorp:4.xfrom
bytes-max:bytes-commerce-file-field

Conversation

@bytes-max
Copy link
Contributor

@bytes-max bytes-max commented Nov 27, 2024

There are constraint issues when attempting to upload a PDF file trough the only "Upload" field there is right now: ImageField. As stated in this task, it might be valuable to have a middle-class (FileField) that is just extended by the ImageField.

@Seb33300
Copy link
Contributor

Seb33300 commented Jan 7, 2025

Even if the ImageField is not really suitable for other type of field, you can override the image constraint on the ImageField like this if you still want to upload something else:

ImageField::new(...)
    ->setFileConstraints(new Assert\File(['extensions' => 'pdf']))

But I agree a new FileField is welcome

@bytes-max
Copy link
Contributor Author

Overriding alone is not sufficient, as it will cause other issues in the core code as far as I remember, since I've tried that before if I am not mistaken... :(

@bytes-max
Copy link
Contributor Author

I was in need for this again, so I just created my own plugin that can do it without any further ado.

If people want to have it, they can refer to this repo: https://packagist.org/packages/bytescommerce/easy-admin-file-upload-field

@bytes-max bytes-max closed this Apr 2, 2025
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

Successfully merging this pull request may close these issues.

2 participants