Commit 96c37ff5 authored by Philippe's avatar Philippe

fix nil error and reformat text

parent 29499e1e
...@@ -5,23 +5,27 @@ local uci = luci.model.uci.cursor() ...@@ -5,23 +5,27 @@ local uci = luci.model.uci.cursor()
local M = {} local M = {}
function M.section(form) function M.section(form)
local text = i18n.translate("gluon-config-mode:zip-help") local text = i18n.translate("gluon-config-mode:zip-help")
local fieldlabel = i18n.translate("ZIP-Code") local fieldlabel = i18n.translate("ZIP-Code")
local s = form:section(cbi.SimpleSection, nil, text) local s = form:section(cbi.SimpleSection, nil, text)
local o = s:option(cbi.Value, "_zip", fieldlabel) local o = s:option(cbi.Value, "_zip", fieldlabel)
o.value = uci:get_first("gluon-node-info", "location", "zip") o.value = uci:get_first("gluon-node-info", "location", "zip")
o.rmempty = true o.rmempty = true
o.datatype = "float" o.datatype = "float"
o.description = i18n.translatef("e.g. %s", "70499") o.description = i18n.translatef("e.g. %s", "70499")
end end
function M.handle(data) function M.handle(data)
local sname = uci:get_first("gluon-node-info", "location") local sname = uci:get_first("gluon-node-info", "location")
uci:set("gluon-node-info", sname, "zip", data._zip:trim())
if data._zip ~= nil then
uci:set("gluon-node-info", sname, "zip", data._zip:trim())
uci:delete("gluon-node-info", sname, "zip")
uci:save("gluon-node-info") uci:save("gluon-node-info")
uci:commit("gluon-node-info") uci:commit("gluon-node-info")
end end
return M return M
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment