Expand sub-arrays that are indexed by form-name ('a[b][c]') into actual sub-arrays so perspectives work properly

This commit is contained in:
Nathan Gray 2011-10-06 23:08:15 +00:00
parent be79886301
commit ed76f0491e

View File

@ -39,6 +39,26 @@ var et2_arrayMgr = Class.extend({
_data = {};
}
// Expand sub-arrays that have been shmushed together, so further perspectives work
if (this.splitIds)
{
for(var key in _data) {
var indexes = key.replace(/]/g,'').split('[');
if(indexes.length > 1)
{
var value = _data[key];
var target = _data;
for(var i = 0; i < indexes.length; i++) {
if(typeof target[indexes[i]] == "undefined") {
target[indexes[i]] = i == indexes.length-1 ? value : {};
}
target = target[indexes[i]];
}
delete _data[key];
}
}
}
this.data = _data;
// Holds information about the current perspective