Hi I have a regular uploadField where I use:-
function getCMSFields()
{
$fields = parent::getCMSFields();
$uploadField = new UploadField( $name = 'RotaFile', $title = 'Upload rota excel file' );
$uploadField->setFolderName('/adminfiles/rota_uploads');
$uploadField->setAllowedExtensions(array('xlsm','xlsx'));
$sizeBytes = 3 * 1024 * 1024 ; // 3 MB in bytes
$uploadField->getValidator()->setAllowedMaxFileSize($sizeBytes);
$uploadField->setCanPreviewFolder(true);
$fields->addFieldToTab( 'Root.ExcelUpload', $uploadField);
return $fields;
}
uploadField validation passes and returns valid - but it then goes into dataobject::write(...) to do a second validation check which fails with "Forbidden" because xlsm is not in the "global" allowed list.
I see in databobject::write(...)
if(Config::inst()->get('DataObject', 'validation_enabled')) {
$valid = $this->validate();
So it's doing a second check (that I don't really want) on the allowed extensions which fails as it just uses the global list which has no xlsm in it..
Can I switch `validation_enabled` off just for this one uploadFile object?
- or do I need to add xlsm file type to my global list of allowed extensions (using File and allowed extensions in _config.yml)?
thanks as ever!
Martin