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.
This commit is contained in:
Ingo Schommer 2013-10-31 21:27:39 +01:00
parent d445c7e369
commit fe6cc6e36e

View File

@ -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