summaryrefslogtreecommitdiffhomepage
path: root/libs/cbi/luasrc/cbi.lua
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2009-03-26 12:37:26 +0000
committerSteven Barth <steven@midlink.org>2009-03-26 12:37:26 +0000
commitb9fbed39cae20547106239127468ad0c0a5d9fea (patch)
tree658115db54078a2ef8bceab992a7c61523df9ffa /libs/cbi/luasrc/cbi.lua
parenta5ffc640635654f2aea77d0fb5892b8067cb8b10 (diff)
Correctly set status FORM_PROCEED instead of FORM_CHANGED if user
creates / deletes a field or section
Diffstat (limited to 'libs/cbi/luasrc/cbi.lua')
-rw-r--r--libs/cbi/luasrc/cbi.lua18
1 files changed, 14 insertions, 4 deletions
diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua
index 88203660c9..aea9b485e6 100644
--- a/libs/cbi/luasrc/cbi.lua
+++ b/libs/cbi/luasrc/cbi.lua
@@ -295,6 +295,7 @@ function Map.__init__(self, config, ...)
self.template = "cbi/map"
self.apply_on_parse = nil
self.readinput = true
+ self.proceed = false
self.uci = uci.cursor()
self.save = true
@@ -349,7 +350,7 @@ function Map.parse(self, readinput, ...)
for i, config in ipairs(self.parsechain) do
self.uci:save(config)
end
- if self:submitstate() and (self.autoapply or luci.http.formvalue("cbi.apply")) then
+ if self:submitstate() and not self.proceed and (self.autoapply or luci.http.formvalue("cbi.apply")) then
for i, config in ipairs(self.parsechain) do
self.uci:commit(config)
@@ -377,7 +378,9 @@ function Map.parse(self, readinput, ...)
end
end
- if self:submitstate() then
+ if self.proceed then
+ self.state = FORM_PROCEED
+ elseif self:submitstate() then
if self.save then
self.state = self.changed and FORM_CHANGED or FORM_VALID
else
@@ -725,6 +728,7 @@ function AbstractSection.parse_optionals(self, section)
if field == v.option then
field = nil
else
+ self.map.proceed = true
table.insert(self.optionals[section], v)
end
end
@@ -763,6 +767,7 @@ function AbstractSection.parse_dynamic(self, section)
end
if create and key:sub(1, 1) ~= "." then
+ self.map.proceed = true
self:add_dynamic(key, true)
end
end
@@ -781,7 +786,7 @@ end
-- Removes the section
function AbstractSection.remove(self, section)
- self.map.autoapply = false
+ self.map.proceed = true
return self.map:del(section)
end
@@ -808,7 +813,7 @@ function AbstractSection.create(self, section)
end
end
- self.map.autoapply = false
+ self.map.proceed = true
return stat
end
@@ -1542,6 +1547,11 @@ function DynamicList.value(self, key, val)
table.insert(self.vallist, tostring(val))
end
+function DynamicList.write(self, ...)
+ self.map.proceed = true
+ return AbstractValue.write(self, ...)
+end
+
function DynamicList.formvalue(self, section)
local value = AbstractValue.formvalue(self, section)
value = (type(value) == "table") and value or {value}