summaryrefslogtreecommitdiffstats
path: root/acf/model/init.lua
diff options
context:
space:
mode:
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