[luci] Evaluating an optin in CBI file

Yegor Yefremov yegorslists at googlemail.com
Mon Aug 19 10:57:13 CEST 2013


I have a config section and two options: one is device ID and the
other a list of possible modes, that depend on device ID. So I want to
know the device ID value and then create a device specific ValueList
("rs232", "rs422" etc.). Is it possible?

config iface port1
          option devid 1
          option mode "rs232"

Possible code:

mysys = s:option(Value, "system", translate("System"))
p = s:option(ListValue, "mode", translate("Mode"))
if mysys == "1" then
        p:value("rs232", "RS-232")
        p:value("rs422", "RS-422")
else
        p:value("rs232", "RS-232")
        p:value("rs422", "RS-422")
        p:value("rs485", "RS-485")
end

Best regards,
Yegor


More information about the luci mailing list