Skip to content

Commit 8d045a2

Browse files
committed
20200107: Hotfixes image upload form submission
fix(js/patternkit.jsoneditor.js)
1 parent e35b2b1 commit 8d045a2

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

js/patternkit.jsoneditor.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -288,17 +288,19 @@
288288
var parent_call = Drupal.Ajax.prototype.beforeSubmit;
289289
Drupal.Ajax.prototype.beforeSubmit = function (formValues, elementSettings, options) {
290290
if (window.patternkitEditor) {
291-
window.patternkitEditor.disable();
292-
saveSchema();
293291
var index = formValues.findIndex(function (o) { return o.name === "settings[instance_config]"; });
294-
formValues[index] = {
295-
name: "settings[instance_config]",
296-
value: JSON.stringify(window.patternkitEditor.getValue()),
297-
type: "hidden",
298-
required: false
299-
};
300-
window.patternkitEditor.destroy();
301-
delete window.patternkitEditor;
292+
if (index !== -1) {
293+
window.patternkitEditor.disable();
294+
saveSchema();
295+
formValues[index] = {
296+
name: "settings[instance_config]",
297+
value: JSON.stringify(window.patternkitEditor.getValue()),
298+
type: "hidden",
299+
required: false
300+
};
301+
window.patternkitEditor.destroy();
302+
delete window.patternkitEditor;
303+
}
302304
}
303305
parent_call.call(this, formValues, elementSettings, options);
304306
};

0 commit comments

Comments
 (0)