From fe6cc6e36e1e873af934277a42a727dce06e99c8 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 31 Oct 2013 21:27:39 +0100 Subject: [PATCH] Conditionally send "ID" val in UploadField The "ID" form field is not always defined, for example in the "Replace" tab of the "versionedfiles" module (which uses GridFieldDetailForm). Since the path to that detail form relies on the "ID" in AssetAdmin->currentPageID(), and does an is_numeric() check to support the "root" folder, we need to leave the "ID" param out completely. Checked this without versionedfiles module in admin/assets as well as a custom UploadField in CMSMain. --- javascript/UploadField.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/javascript/UploadField.js b/javascript/UploadField.js index d9400e20d..e4425ba94 100644 --- a/javascript/UploadField.js +++ b/javascript/UploadField.js @@ -186,13 +186,10 @@ { formData: function(form) { var idVal = $(form).find(':input[name=ID]').val(); - if(!idVal) { - idVal = 0; - } - return [ - {name: 'SecurityID', value: $(form).find(':input[name=SecurityID]').val()}, - {name: 'ID', value: idVal} - ]; + var data = [{name: 'SecurityID', value: $(form).find(':input[name=SecurityID]').val()}]; + if(idVal) data.push({name: 'ID', value: idVal}); + + return data; }, errorMessages: { // errorMessages for all error codes suggested from the plugin author, some will be overwritten by the config coming from php