Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions src/js/brutusin-json-forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -1270,13 +1270,24 @@ if (typeof brutusin === "undefined") {
}

function getInitialValue(id) {
var ret;
try {
eval("ret = initialValue" + id.substring(1));
} catch (e) {
ret = null;
var fields = id.substring(2).split('.');
var initialValueClone = initialValue;
for(var i = 0; i < fields.length; i++) {
var field = fields[i];
if (field != "") {
if (field.substring(field.length - 1) === "]") {
//Get the index from the array in the field
var arrayIndex = parseInt(field.substring(field.lastIndexOf("[") + 1, field.length - 1));
//Substring off the square bracket from the field
field = field.substring(0, field.lastIndexOf("["));
initialValueClone = initialValueClone[field][arrayIndex];
} else {
initialValueClone = initialValueClone[field];
}
}
}
return ret;

return initialValueClone;
}

function getValue(schema, input) {
Expand Down