summaryrefslogtreecommitdiffstats
path: root/acf
diff options
context:
space:
mode:
Diffstat (limited to 'acf')
-rw-r--r--acf/model/init.lua2
-rw-r--r--acf/model/node.lua7
2 files changed, 6 insertions, 3 deletions
diff --git a/acf/model/init.lua b/acf/model/init.lua
index 895ed62..f325053 100644
--- a/acf/model/init.lua
+++ b/acf/model/init.lua
@@ -195,7 +195,7 @@ function Collection:init(params, itype)
assert(self.type)
self.itype = itype or node.Collection
- self.iparams = {required=self.required}
+ self.iparams = {required=self.required, destroy=self.destroy}
self.dtype = 'collection'
self.widget = self.dtype
diff --git a/acf/model/node.lua b/acf/model/node.lua
index afc3e0f..47a15c7 100644
--- a/acf/model/node.lua
+++ b/acf/model/node.lua
@@ -117,8 +117,11 @@ function Collection:init(context, params)
function mt.members() return mt.txn:get(mt.addr, 'table') or {} end
function mt.validate()
- if params.required and #mt.members() == 0 then
- raise(mt.path, 'Collection cannot be empty')
+ if #mt.members() > 0 then return end
+ if params.required then raise(mt.path, 'Collection cannot be empty') end
+ if params.destroy then
+ mt.txn:set(mt.addr)
+ validate(mt.parent)
end
end