Hi;
I am attempting to conditionally add buttons to sections based on section values in a config file. Code below.
What I am seeing is that despite the if (status == "none") condition being met for only one of four sections, all four sections have buttons added.
The messages printed are:
"section1 here section2 else section3 else section4 else" indicating that the "if" is working.
The question is: does placing a button in one (s.addremove = true) section create buttons for all other sections, as it appears? How can I avoid this, or, am I missing something?
Thanks;
Bill
uci:foreach( "license", "license", function(z)
if uci:get("license", z['.name'], "status") == "none" then
btn = s:option( Button, "_btn", translate("Request License"), "")
btn.value = "Request"
function btn.write(self, section, value)
local cmd = "vtdaemon -S " .. section .. " -R"
cmdret = luci.sys.exec( cmd )
fs.writefile(resultsfile, cmdret:gsub("\r\n", "\n"))
return reload
end
m.message = m.message .. z['.name'] .. " here "
else
m.message = m.message .. z['.name'] .. " else "
end
end )