diff options
-rw-r--r-- | acf/model/field.lua | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/acf/model/field.lua b/acf/model/field.lua index a186064..1c903b0 100644 --- a/acf/model/field.lua +++ b/acf/model/field.lua @@ -182,14 +182,9 @@ end function TreeNode:save(context, value) local path = context.path - -- TODO hack, allow preserving old instance on parent update if value == path then return end - - if object.isinstance(value, node.TreeNode) then - -- TODO clone if TreeNode has wrong path - if node.path(value) ~= path then - raise(path, 'Attempted to assign foreign object as value') - end + if type(value) == 'string' then value = context.txn:search(value) end + if object.isinstance(value, node.TreeNode) and node.path(value) == path then return end @@ -204,7 +199,7 @@ function TreeNode:save(context, value) local new = self:load(context, true) local errors = err.ErrorDict() - for k, v in pairs(value) do + for k, v in node.pairs(value) do errors:collect(self.save_member, new, k, v) end errors:raise() |