Commit b7620d48 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 40dc3033
...@@ -158,7 +158,6 @@ ...@@ -158,7 +158,6 @@
JSONEditor.defaults.editors.multiple.prototype.setValue = function (val, initial) { JSONEditor.defaults.editors.multiple.prototype.setValue = function (val, initial) {
/* Determine type by getting the first one that validates */ /* Determine type by getting the first one that validates */
var field = this, var field = this,
typeChanged, typeChanged,
prevType = this.type, prevType = this.type,
...@@ -214,7 +213,11 @@ ...@@ -214,7 +213,11 @@
finalI = field.getIfType(val); finalI = field.getIfType(val);
} }
if (finalI === null) { if (finalI === null) {
if (isEmpty(val)) {
finalI = field.type; finalI = field.type;
} else {
throw new Error("Could not safely render data into the form.")
}
} }
field.type = finalI; field.type = finalI;
field.switcher.value = field.display_text[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