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
@ -645,7 +645,7 @@ class Image_Uploader extends Controller {
|
|||||||
}
|
}
|
||||||
$owner = DataObject::get_by_id($data['Class'], $data['ID']);
|
$owner = DataObject::get_by_id($data['Class'], $data['ID']);
|
||||||
$fieldName = $data['Field'] . 'ID';
|
$fieldName = $data['Field'] . 'ID';
|
||||||
|
|
||||||
if($data['ImageSource'] == 'existing') {
|
if($data['ImageSource'] == 'existing') {
|
||||||
if(!$data['ExistingFile']) {
|
if(!$data['ExistingFile']) {
|
||||||
// No image has been selected
|
// No image has been selected
|
||||||
@ -658,6 +658,14 @@ class Image_Uploader extends Controller {
|
|||||||
// Edit the class name, if applicable
|
// Edit the class name, if applicable
|
||||||
$existingFile = DataObject::get_by_id("File", $data['ExistingFile']);
|
$existingFile = DataObject::get_by_id("File", $data['ExistingFile']);
|
||||||
$desiredClass = $owner->has_one($data['Field']);
|
$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)) {
|
if(!is_a($existingFile, $desiredClass)) {
|
||||||
$existingFile->ClassName = $desiredClass;
|
$existingFile->ClassName = $desiredClass;
|
||||||
$existingFile->write();
|
$existingFile->write();
|
||||||
|
Loading…
Reference in New Issue
Block a user