From 0d4aa8678943dcd7d7a3cd03a2ed395e6e0efff4 Mon Sep 17 00:00:00 2001 From: Romain Louis Date: Thu, 1 Nov 2007 05:31:58 +0000 Subject: [PATCH] Delete problem fixing : When you delete an image with ImageField it only deletes the link not the image git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@44099 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/Image.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/model/Image.php b/core/model/Image.php index fc129f49a..e4dd3fdd0 100755 --- a/core/model/Image.php +++ b/core/model/Image.php @@ -594,7 +594,9 @@ class Image_Uploader extends Controller { $this, 'DeleteImageForm', new FieldSet( + new HiddenField("Class", null, $this->urlParams['Class']), new HiddenField("ID", null, $this->urlParams['ID']), + new HiddenField("Field", null, $this->urlParams['Field']), new HeaderField($title), new LabelField( sprintf( @@ -677,8 +679,10 @@ class Image_Uploader extends Controller { * Delete the image referenced by this form. */ function delete($data, $form) { - $image = $this->Image(); - $image->delete(); + $owner = DataObject::get_by_id( $data[ 'Class' ], $data[ 'ID' ] ); + $fieldName = $data[ 'Field' ] . 'ID'; + $owner->$fieldName = 0; + $owner->write(); Director::redirect($this->Link('iframe')); }