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
This commit is contained in:
Romain Louis 2007-11-01 05:31:58 +00:00
parent e78c785f0d
commit 0d4aa86789

View File

@ -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'));
}