From 0a85936f2f1f48517f8e8ad70a2d22c98112b712 Mon Sep 17 00:00:00 2001 From: Romain Louis Date: Wed, 17 Oct 2007 23:10:04 +0000 Subject: [PATCH] FileIFrame Saving method problem fixing git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@43542 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/FileIFrameField.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/forms/FileIFrameField.php b/forms/FileIFrameField.php index 4e6f9c20d..6948e2954 100755 --- a/forms/FileIFrameField.php +++ b/forms/FileIFrameField.php @@ -25,5 +25,21 @@ class FileIFrameField extends FileField { return FormField::Field(); } } + + public function saveInto(DataObject $record) { + $fieldName = $this->name . 'ID'; + $hasOnes = $record->has_one($this->name); + if(!$hasOnes) $hasOnes = $record->has_one($fieldName); + + // assume that the file is connected via a has-one + if( !$hasOnes || !$_FILES[$this->name]['name']){ + return; + } + + $file = new File(); + $file->loadUploaded($_FILES[$this->name]); + + $record->$fieldName = $file->ID; + } } ?> \ No newline at end of file