[luci] a validation problem
Ugur Dogru
udogru at ubicom.com
Tue Feb 9 17:42:02 CET 2010
Hi,
I am trying to write a validation function for start and limit fields in dhcp page.
for now, there is no limit to add a new dhcp range and you can add ovarlapping ranges.
To disable this, I wrote a validation function like that:
start = s:option(Value, "start", translate("start"))
start.rmempty = true
function start:validate(value)
local result = true
m.uci:foreach("dhcp", "dhcp", function(d)
local dhcp_start = tonumber(d.start)
local dhcp_end = tonumber(d.start) + tonumber(d.limit)
if tonumber(value) > dhcp_start and tonumber(value) < dhcp_end then
result = false
end
end)
if result == false then
return false
end
return value
end
Problem is if you are updating an existing dhcp range, it checks itself and fails. How can I solve this problem?
thanks
~ugur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.subsignal.org/pipermail/luci/attachments/20100209/4959fa58/attachment.htm
More information about the luci
mailing list