OpenWrt Forum Archive

Topic: Problem using MultiValue in LuCi

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

LuCi Test

Hi All,
I'm starting the programming in LuCi/Lua, so my question may be stupid, but:
i use the following code

...
s:taboption("select_menue", DummyValue,"name")  

s:taboption("action_menue",DummyValue, "err1")


i=s:taboption("action_menue", MultiValue, "switches", translate("Aviable Switches: "))
i:value("err_1", "err1")
i:value("err_2", "err2")
...

why is the content of Variable "err1" visible in the first case, but not in the second? 

Any help is appreciated.

Regards,

What do you mean with "content of variable" here? All items look the same to me in your screenshot.

Hi jow,

thanks for replay.

i mean, the content of the variable "err1" (or "err2" etc.) are a string (-> "Injection Pin...").

In the first case:

s:taboption("action_menue",DummyValue, "err1")

I can see this string on the screen.

In the second case

i=s:taboption("action_menue", MultiValue, "switches", translate("Aviable Switches: "))
i:value("err_1", "err1")

not.
The "Lua Reference Manual" says :

The scope of a local variable begins at the first statement after its declaration and lasts until the last non-void statement of the innermost block that includes the declaration.

that's why I'm confused about these differences in the representation.

Regards,

There is no variable called err1 in your code, just a string that happens to contain the letters "err1". Unfortunately I still don't understand your problem.

Hello jow,

I thought completely wrong at this point...
The Documentation for LuCi is but also... "homöophatisch"!

Thanks for your Help!

It the code you posted, err1 is never assigned a value, therefore its value is nil and not displayed. However, in your MultiValue code, you are assigning the selected item/s value/s to the variable "switches" variable.


It's not clear what you are trying to accomplish but if i had to hazard a guess, I think this is what you are trying to achieve...


...
s:taboption("user", DummyValue,"name")  
s:taboption("user", DummyValue, "switches")

i=s:taboption("user", MultiValue, "switches", translate("Aviable Switches: "))
i:value("err_1", "err1")
i:value("err_2", "err2")

...

note, until you save (assign the values) by pressing the "save" or "save and apply" button no value/s will be displayed in the "switches" DummyValue

(Last edited by hostle19 on 30 Oct 2015, 22:07)

The discussion might have continued from here.