silverstripe-framework/forms/FileIFrameField.php
Ingo Schommer cb860c2f75 Merged revisions 47612 via svnmerge from
svn://svn.silverstripe.com/silverstripe/modules/sapphire/branches/2.2.0-mesq

........
  r47612 | ischommer | 2008-01-04 19:11:57 +1300 (Fri, 04 Jan 2008) | 1 line
  
  formatting, removed saveInto() (same functionality as parent-class)
........


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@52198 467b73ca-7a2a-4603-9d3b-597d59a354a9
2008-04-06 04:08:03 +00:00

32 lines
935 B
PHP
Executable File

<?php
/**
* A field that will upload files to a page for use within the CMS.
*
* @package forms
* @subpackage fields-files
*/
class FileIFrameField extends FileField {
public function Field() {
$data = $this->form->getRecord();
if($data->ID && is_numeric($data->ID)) {
$idxField = $this->name . 'ID';
$hiddenField = "<input type=\"hidden\" id=\"" . $this->id() . "\" name=\"$idxField\" value=\"" . $this->attrValue() . "\" />";
$parentClass = $data->class;
$parentID = $data->ID;
$parentField = $this->name;
$iframe = "<iframe name=\"{$this->name}_iframe\" src=\"images/iframe/$parentClass/$parentID/$parentField\" style=\"height: 152px; width: 600px; border-style: none;\"></iframe>";
return $iframe . $hiddenField;
} else {
$this->value = _t('FileIframeField.NOTEADDFILES', 'You can add files once you have saved for the first time.');
return FormField::Field();
}
}
}
?>