summaryrefslogtreecommitdiffstats
path: root/acf/model/init.lua
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2013-05-08 17:37:40 +0300
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2013-05-08 23:07:00 +0300
commit16331a3ae0dcd283e2f4b7f6230742e47d1b7cb3 (patch)
tree0b6c3e71f687b2c9d90462a9992b7355813ab546 /acf/model/init.lua
parent29859154a1b0cd9600a05549e447843103b7eb9d (diff)
downloadaconf-16331a3ae0dcd283e2f4b7f6230742e47d1b7cb3.tar.bz2
aconf-16331a3ae0dcd283e2f4b7f6230742e47d1b7cb3.tar.xz
explicit control for automatic creation of TreeNode instances
Diffstat (limited to 'acf/model/init.lua')
-rw-r--r--acf/model/init.lua17
1 files changed, 9 insertions, 8 deletions
diff --git a/acf/model/init.lua b/acf/model/init.lua
index ed06548..895ed62 100644
--- a/acf/model/init.lua
+++ b/acf/model/init.lua
@@ -189,20 +189,21 @@ Model = fld.Model
Collection = class(fld.TreeNode)
-function Collection:init(params, ctype)
+function Collection:init(params, itype)
+ if params.create == nil then params.create = true end
super(self, Collection):init(params)
+
assert(self.type)
- self.ctype = ctype or node.Collection
+ self.itype = itype or node.Collection
+ self.iparams = {required=self.required}
+
self.dtype = 'collection'
self.widget = self.dtype
end
-function Collection:load(context)
- -- automatically create missing collection (TODO: make this configurable?)
- return self.ctype(
- context,
- {field=to_field(self.type), required=self.required}
- )
+function Collection:load(context, create)
+ if not self.iparams.field then self.iparams.field = to_field(self.type) end
+ return super(self, Collection):load(context, create)
end