summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-08-30 10:18:56 +0000
committerSteven Barth <steven@midlink.org>2008-08-30 10:18:56 +0000
commit7e792dad2e8be495009f4b78856fb9797a7de019 (patch)
treeacc59fd46fcf12c4773dc73c5096394faf6d4bff /libs
parentccf73ec14ea31673250ac28d5b51883b474d231e (diff)
libs/cbi: Create section after validation to avoid validation errors with empty fields
Diffstat (limited to 'libs')
-rw-r--r--libs/cbi/luasrc/cbi.lua58
1 files changed, 30 insertions, 28 deletions
diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua
index 7dabe2d60..9c5501d69 100644
--- a/libs/cbi/luasrc/cbi.lua
+++ b/libs/cbi/luasrc/cbi.lua
@@ -699,35 +699,9 @@ end
function TypedSection.parse(self)
if self.addremove then
- -- Create
- local crval = CREATE_PREFIX .. self.config .. "." .. self.sectiontype
- local name = luci.http.formvalue(crval)
- if self.anonymous then
- if name then
- self:create()
- end
- else
- if name then
- -- Ignore if it already exists
- if self:cfgvalue(name) then
- name = nil;
- end
-
- name = self:checkscope(name)
-
- if not name then
- self.err_invalid = true
- end
-
- if name and #name > 0 then
- self:create(name)
- end
- end
- end
-
-- Remove
- crval = REMOVE_PREFIX .. self.config
- name = luci.http.formvaluetable(crval)
+ local crval = REMOVE_PREFIX .. self.config
+ local name = luci.http.formvaluetable(crval)
for k,v in pairs(name) do
if self:cfgvalue(k) and self:checkscope(k) then
self:remove(k)
@@ -765,6 +739,34 @@ function TypedSection.parse(self)
end
AbstractSection.parse_optionals(self, k)
end
+
+ if self.addremove then
+ -- Create
+ local crval = CREATE_PREFIX .. self.config .. "." .. self.sectiontype
+ local name = luci.http.formvalue(crval)
+ if self.anonymous then
+ if name then
+ self:create()
+ end
+ else
+ if name then
+ -- Ignore if it already exists
+ if self:cfgvalue(name) then
+ name = nil;
+ end
+
+ name = self:checkscope(name)
+
+ if not name then
+ self.err_invalid = true
+ end
+
+ if name and #name > 0 then
+ self:create(name)
+ end
+ end
+ end
+ end
end
-- Verifies scope of sections