json-forms
json-forms copied to clipboard
Nulls are returned instead of empty strings
When new sting elements are added and they are not filled with any data, nulls are returned instead. However it should be empty strings according to the schema.
See the screenshot:
function processOptions(parentId, names, data, cb) { var schemas = {}; var schema = { type: "string" };
if (data[parentId] === "efg") { schema.title = "efg"; schema.enum = ["", ""]; } else if (data[parentId] === "abc") { schema.title = "abc"; schema.enum = ["", ""]; }
// Check for null values and convert them to empty strings var subOptionValue = data[parentId + ".suboption1"]; if (subOptionValue === null) { subOptionValue = ""; }
schemas["$.sub" + parentId] = schema; schemas["$.sub" + parentId].default = subOptionValue; setTimeout(function() { cb(schemas); }, 500); // in order to show asynchrony }