Silverstripe Version: 5.2
Question:
Hi there, we’re using the UploadField
for both images and files and want to add validation for allowed file types.
I’m sure before I could do the following and it would :
private static array $has_one = [
'Video' => File::class, // No validation
// Video' => Image::class // Has validation
];
$fldVideo = UploadField::create('Video', 'Video');
$fldVideoValidator = $fldVideo->getValidator();
$fldVideoValidator->setAllowedExtensions(['jpg', 'jpeg', 'png']);
$fldVideoValidator->setAllowedMaxFileSize('300kb');
$fldVideo->setFolderName('Uploads/large');
It seems to validate if the $has_one
uses an Image::class
, but doesn’t validate if it’s a File::class
. Is this intended?
Thanks,
Jack