OpenWrt Forum Archive

Topic: LuCi "depends: linked with OR

The content of this topic has been archived on 1 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,

The Documentation/CBI - LuCI page shows that the "depends" parameter is linked with "OR".  Is there a way to link them with "AND"??

I have a case where, for example my uci file is called "otra".

config mysection
   option speed 'Fast'
   option mode 'Manual'
   option foo 'the_foo_val'
   option foo2 'myfoo2'

In my ../model/cbi/otra.lua file
x = s:option(Value, "foo", "Ask for foo value only if Speed is fast and mode is auto")
   x:depends("speed", "Fast")
   x:depends("mode", "Auto")

Since it's linked with "OR" if either speed == Fast OR mode == Auto", the GUI will display the request for the foo value.  I really only want the question asked if both conditions are true. 

Would it be better to use a function to get the uci values then combine them.  Similar to something like
   function x.cfgvalue(self,s)
         speedval = self.map:get(s, "speed")
         modeval = self.map:get(s, "mode")
    end

I would like to know this as well.

+1

The discussion might have continued from here.