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
Pipeline #34057 failed with stage
in 0 seconds
...@@ -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