[luci] Changes not saved in CBI after Save

Tomasz Mrugalski spam at klub.com.pl
Mon Mar 1 02:43:09 CET 2010


Hi,

I'm trying to create simple configuration for tunnels. There are 2 
possible tunnel types: Softwire, DS-Lite (no tunnel at all is also 
valid choice). Each tunnel can be configured statically or using DHCP. I 
want configuration for softwire visible only if tunnel type is softwire. 
The same holds true for DS-Lite. If I choose one tunnel type, 
configuration parameter for the other should not be removed from config 
file (it will just be ignored by my scripts). Specified config file 
(mantun) is readable and contains necessary entries.

Here is my simplified code:

-- print all values sent in POST 
post = luci.http.formvalue(nil)
luci.util.dumptable(post)

mantun = Map("mantun", "Tunnel configuration")

m = mantun:section(TypedSection, "mantun", "Tunnel cfg")
m.anonymous = true

tunnelMode = m:option(ListValue,"type", "Tunnel type")
tunnelMode:value("0","Softwire")
tunnelMode:value("1","DS-Lite")
tunnelMode:value("2","Disable")

swMode = m:option(ListValue,"swMode", "Softwire mode")
swMode:value("0","DHCP")
swMode:value("1","static")
swMode.rmempty = false
swMode:depends("type","0")

dsMode = m:option(ListValue,"dsMode", "DS-Lite mode")
dsMode:value("0","DHCP")
dsMode:value("1","static")
dsMode.rmempty = false
dsMode:depends("type","1")

return mantun

The problem: Save or Save&Apply does not save values at all! I can change 
tunnel type and appropriate options are shown or disappear. However, once 
I click save, changes are sent via POST (I've checked that proper values 
are sent). Unfortunately, they are NOT SAVED or added to list of changes 
to be applied! For example: after changing tunnel type from softwire to 
DS-Lite and clicking save, I would expect to see that there is 1 change.

I've found kind of workaround, but I'm not comfortable with it.
Changes are saved, if I do one of the following things:
- remove :depends() instructions
- remove .rmempty = true

This looks like a bug in POST processing. I'm willing to fix it, but I 
need some guidance.

Tomek Mrugalski

p.s.
I've added possibility to hide whole maps (very useful, if you want to 
edit several configs on one page). Should I submit bug and attach a patch?


More information about the luci mailing list