form->getRecord();
$parentID = ($id && is_numeric($id)) ? $id : (isset($data) ? $data->ID : 0);
if($data && $parentID && is_numeric($parentID)) {
$idxField = $this->name . 'ID';
$hiddenField = "id() . "\" name=\"$idxField\" value=\"" . $this->attrValue() . "\" />";
$parentClass = $data->class;
$parentField = $this->name;
$iframe = "";
return $iframe . $hiddenField;
} else {
$this->value = 'You can add images once you have saved for the first time.';
return FormField::Field();
}
}
public function saveInto($record) {
$data = $this->form->getRecord();
// if the record was written for the first time (has an arbitrary "new"-ID), update the imagefield to enable uploading
if($record->ID && substr($data->ID,0,3) == 'new') {
FormResponse::update_dom_id($this->id(), $this->Field($record->ID));
}
}
/**
* Returns a readonly version of this field
*/
function performReadonlyTransformation() {
$field = new SimpleImageField_Disabled($this->name, $this->title, $this->value);
$field->setForm($this->form);
return $field;
}
}
?>