X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=libs%2Fcbi%2Fluasrc%2Fcbi.lua;h=f733560caf88e1395b9a788c83a3aa98c755acec;hp=2d439b8bc69a82166b578be8565a154a111bd2dd;hb=a5cb3b04cb9bdfe10b49edcb6b1f093cdd86cdb4;hpb=e0e58e842dbe7531bb7ae8b53f487e0fe9a92415 diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua index 2d439b8bc..f733560ca 100644 --- a/libs/cbi/luasrc/cbi.lua +++ b/libs/cbi/luasrc/cbi.lua @@ -568,6 +568,7 @@ function SimpleForm.parse(self, readinput, ...) valid = valid and (not v.tag_missing or not v.tag_missing[1]) and (not v.tag_invalid or not v.tag_invalid[1]) + and (not v.error) end end @@ -986,7 +987,7 @@ function TypedSection.parse(self, novld) for i, k in ipairs(self:cfgsections()) do AbstractSection.parse_dynamic(self, k) if self.map:submitstate() then - Node.parse(self, k) + Node.parse(self, k, novld) if not novld and not self.override_scheme and self.map.scheme then _uvl_validate_section(self, k) @@ -1167,14 +1168,19 @@ function AbstractValue.mandatory(self, value) self.rmempty = not value end -function AbstractValue.parse(self, section) +function AbstractValue.parse(self, section, novld) local fvalue = self:formvalue(section) local cvalue = self:cfgvalue(section) if fvalue and #fvalue > 0 then -- If we have a form value, write it to UCI fvalue = self:transform(self:validate(fvalue, section)) - if not fvalue then - self.tag_invalid[section] = true + if not fvalue and not novld then + if self.error then + self.error[section] = "invalid" + else + self.error = { [section] = "invalid" } + end + self.map.save = false end if fvalue and not (fvalue == cvalue) then if self:write(section, fvalue) then @@ -1190,8 +1196,14 @@ function AbstractValue.parse(self, section) self.section.changed = true --luci.util.append(self.map.events, self.events) end - elseif self.track_missing and (not fvalue or fvalue ~= cvalue) then - self.tag_missing[section] = true + elseif cvalue ~= fvalue and not novld then + self:write(section, fvalue or "") + if self.error then + self.error[section] = "missing" + else + self.error = { [section] = "missing" } + end + self.map.save = false end end end