Commit 832f69f9 authored by Rafael Monnerat's avatar Rafael Monnerat

erp5_json_editor: Throw error if the field cannot decide which form to render

   This prevents loose data and wrong edits.
parent 5fde6a1f
......@@ -158,7 +158,6 @@
JSONEditor.defaults.editors.multiple.prototype.setValue = function (val, initial) {
/* Determine type by getting the first one that validates */
var field = this,
typeChanged,
prevType = this.type,
......@@ -214,7 +213,11 @@
finalI = field.getIfType(val);
}
if (finalI === null) {
finalI = field.type;
if (isEmpty(val)) {
finalI = field.type;
} else {
throw new Error("Could not safely render data into the form.")
}
}
field.type = finalI;
field.switcher.value = field.display_text[finalI];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment