From 4a9a64f191d32130d2e86eacfaf0cf9e1bdf4c64 Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Fri, 27 Sep 2013 11:35:27 +0300 Subject: web client: multi-checkbox widget for reference sets --- acf/model/init.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'acf/model/init.lua') diff --git a/acf/model/init.lua b/acf/model/init.lua index 78f5032..1de5202 100644 --- a/acf/model/init.lua +++ b/acf/model/init.lua @@ -47,6 +47,7 @@ M.node.Set = require('acf.model.set').Set local object = require('acf.object') local class = object.class +local isinstance = object.isinstance local super = object.super local pth = require('acf.path') @@ -97,7 +98,7 @@ function M.Reference:_validate(context, value) if value == nil then return end - if object.isinstance(value, node.TreeNode) then value = node.path(value) end + if isinstance(value, node.TreeNode) then value = node.path(value) end local path = context.path if type(value) ~= 'string' then raise(path, 'Path name must be string') end @@ -169,7 +170,12 @@ function M.List:init(params) super(self, M.List):init(params, node.List) end M.Set = class(M.Collection) -function M.Set:init(params) super(self, M.Set):init(params, M.node.Set) end +function M.Set:init(params) + if not params.widget and isinstance(params.type, M.Reference) then + params.widget = 'checkboxes' + end + super(self, M.Set):init(params, M.node.Set) +end function M.Set.save_member(tn, k, v) node.insert(tn, v) end -- cgit v1.2.3