mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
#892 - Error attaching an existing folder to an ImageField
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@47941 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
6afd4655de
commit
e87b76b305
@ -658,6 +658,14 @@ class Image_Uploader extends Controller {
|
||||
// Edit the class name, if applicable
|
||||
$existingFile = DataObject::get_by_id("File", $data['ExistingFile']);
|
||||
$desiredClass = $owner->has_one($data['Field']);
|
||||
|
||||
// Unless specifically asked, we don't want the user to be able
|
||||
// to select a folder
|
||||
if(is_a($existingFile, 'Folder') && $desiredClass != 'Folder') {
|
||||
Director::redirectBack();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!is_a($existingFile, $desiredClass)) {
|
||||
$existingFile->ClassName = $desiredClass;
|
||||
$existingFile->write();
|
||||
|
Loading…
Reference in New Issue
Block a user