modules/admin-full: allow special value "ignore" for static lease ip address (#558)
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_network / dhcp.lua
index 561f82a..7b5a42c 100644 (file)
@@ -178,7 +178,7 @@ lm.placeholder = translate("unlimited")
 
 em = s:taboption("advanced", Value, "ednspacket_max",
        translate("<abbr title=\"maximal\">Max.</abbr> <abbr title=\"Extension Mechanisms for " ..
-               "Domain Name System\">EDNS0</abbr> paket size"),
+               "Domain Name System\">EDNS0</abbr> packet size"),
        translate("Maximum allowed size of EDNS.0 UDP packets"))
 
 em.optional = true
@@ -235,10 +235,11 @@ name.datatype = "hostname"
 name.rmempty  = true
 
 mac = s:option(Value, "mac", translate("<abbr title=\"Media Access Control\">MAC</abbr>-Address"))
-mac.datatype = "macaddr"
+mac.datatype = "list(macaddr)"
+mac.rmempty  = true
 
 ip = s:option(Value, "ip", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Address"))
-ip.datatype = "ip4addr"
+ip.datatype = "or(ip4addr,'ignore')"
 
 sys.net.arptable(function(entry)
        ip:value(entry["IP address"])
@@ -248,5 +249,14 @@ sys.net.arptable(function(entry)
        )
 end)
 
+function ip.validate(self, value, section)
+       local m = mac:formvalue(section) or ""
+       local n = name:formvalue(section) or ""
+       if value and #n == 0 and #m == 0 then
+               return nil, translate("One of hostname or mac address must be specified!")
+       end
+       return Value.validate(self, value, section)
+end
+
 
 return m