summaryrefslogtreecommitdiffhomepage
path: root/libs/cbi/luasrc/cbi.lua
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-08-04 17:16:27 +0000
committerSteven Barth <steven@midlink.org>2008-08-04 17:16:27 +0000
commit084db952ce2aa302a42f35fa34866f34cb06ba99 (patch)
tree41bcdef71918816ff78de209455edf1162fc8a9f /libs/cbi/luasrc/cbi.lua
parent513e1cbba9e8ba98cc0b4f667aa89233b72b4dd1 (diff)
libs/cbi: Added value function to luci.cbi.Value to create Comboboxes
Diffstat (limited to 'libs/cbi/luasrc/cbi.lua')
-rw-r--r--libs/cbi/luasrc/cbi.lua20
1 files changed, 10 insertions, 10 deletions
diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua
index fe99f0246b..8c8f68b24a 100644
--- a/libs/cbi/luasrc/cbi.lua
+++ b/libs/cbi/luasrc/cbi.lua
@@ -595,7 +595,10 @@ function AbstractValue.render(self, s, scope)
if cond then
return string.format(
' %s="%s"', tostring(key),
- tostring( val or scope[key] or self[key] or "" )
+ tostring( val
+ or scope[key]
+ or (type(self[key]) ~= "function" and self[key])
+ or "" )
)
else
return ''
@@ -642,17 +645,14 @@ Value = class(AbstractValue)
function Value.__init__(self, ...)
AbstractValue.__init__(self, ...)
self.template = "cbi/value"
-
- self.maxlength = nil
+ self.keylist = {}
+ self.vallist = {}
end
--- This validation is a bit more complex
-function Value.validate(self, val)
- if self.maxlength and tostring(val):len() > self.maxlength then
- val = nil
- end
-
- return val
+function Value.value(self, key, val)
+ val = val or key
+ table.insert(self.keylist, tostring(key))
+ table.insert(self.vallist, tostring(val))
end