summaryrefslogtreecommitdiffstats
path: root/acf/model/field.lua
diff options
context:
space:
mode:
Diffstat (limited to 'acf/model/field.lua')
-rw-r--r--acf/model/field.lua17
1 files changed, 8 insertions, 9 deletions
diff --git a/acf/model/field.lua b/acf/model/field.lua
index a784b44..98a4397 100644
--- a/acf/model/field.lua
+++ b/acf/model/field.lua
@@ -77,15 +77,15 @@ function Field:meta(context)
return res
end
-function Field:btype(context) return self.dtype end
-
function Field:topology(context)
- return {{path=context.path, addr=context.addr}}
+ return {
+ {path=context.path, addr=context.addr, type=self.dtype}
+ }
end
function Field:load(context)
if not context.txn then return setmetatable({}, context) end
- local value = context.txn:get(context.addr, self:btype(context))
+ local value = context.txn:get(context.addr)
if value == nil then return self.default end
return value
end
@@ -104,9 +104,7 @@ end
function Field:validate(context, value) end
function Field:save(context, value)
- context.txn:set(
- context.addr, self:btype(context), self:_validate(context, value)
- )
+ context.txn:set(context.addr, self:_validate(context, value))
end
function Field:validate_saved(context)
@@ -179,13 +177,14 @@ TreeNode = class(Field)
function TreeNode:topology(context)
local res = super(self, TreeNode):topology(context)
+ res[1].type = 'table'
util.extend(res, node.topology(self:load(context, true)))
return res
end
function TreeNode:load(context, create)
if context.txn and not (
- create or self.create or context.txn:get(context.addr, 'table')
+ create or self.create or context.txn:get(context.addr)
) then return end
return self.itype(context, self.iparams)
end
@@ -206,7 +205,7 @@ function TreeNode:save(context, value)
raise(path, 'Cannot assign primitive value')
end
- context.txn:set(context.addr, 'table')
+ context.txn:set(context.addr, {})
local new = self:load(context, true)
local errors = err.ErrorDict()