From 8d4b24b68d57d1601a8042c8e51981320d87066e Mon Sep 17 00:00:00 2001 From: Stephen Shkardoon Date: Tue, 10 Sep 2013 21:03:42 +1200 Subject: [PATCH] FIX Don't show the upload field when inappropriate This fix is quite ugly, but in theory, it's fine. By ugly, I mean the interface is kind of weird without it. Because 3.1 allows uploading when a DataObject doesn't exist, we need to override the new defaults to not allow such if the DO isn't saved yet. --- code/cms/DMSUploadField.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/code/cms/DMSUploadField.php b/code/cms/DMSUploadField.php index d3a92f4..4a87bd0 100644 --- a/code/cms/DMSUploadField.php +++ b/code/cms/DMSUploadField.php @@ -57,6 +57,15 @@ class DMSUploadField extends UploadField { return true; } + + public function isDisabled() { + return (parent::isDisabled() || !$this->isSaveable()); + } + + public function isSaveable() { + return (!empty($this->getRecord()->ID)); + } + /** * Action to handle upload of a single file *