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.lua14
1 files changed, 12 insertions, 2 deletions
diff --git a/acf/model/field.lua b/acf/model/field.lua
index 1c903b0..beb6b28 100644
--- a/acf/model/field.lua
+++ b/acf/model/field.lua
@@ -14,7 +14,7 @@ local object = require('acf.object')
local class = object.class
local super = object.super
-local map = require('acf.util').map
+local util = require('acf.util')
local function contains(list, value)
@@ -52,7 +52,7 @@ function Field:init(params)
super(self, Field):init(params)
if self.choice and not self['ui-choice'] then
- self['ui-choice'] = map(
+ self['ui-choice'] = util.map(
function(name) return self:auto_ui_name(name) end,
self.choice
)
@@ -79,6 +79,10 @@ end
function Field:btype(context) return self.dtype end
+function Field:topology(context)
+ return {{path=context.path, addr=context.addr}}
+end
+
function Field:load(context)
local value = context.txn:get(context.addr, self:btype(context))
if value == nil then return self.default end
@@ -172,6 +176,12 @@ end
TreeNode = class(Field)
+function TreeNode:topology(context)
+ local res = super(self, TreeNode):topology(context)
+ util.extend(res, node.topology(self:load(context, true)))
+ return res
+end
+
function TreeNode:load(context, create)
if not (
create or self.create or context.txn:get(context.addr, 'table')