FileIFrame Saving method problem fixing

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@43542 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Romain Louis 2007-10-17 23:10:04 +00:00
parent c485a70354
commit 0a85936f2f

View File

@ -25,5 +25,21 @@ class FileIFrameField extends FileField {
return FormField::Field(); 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;
}
} }
?> ?>