When I go to save, it only writes the FTP information for the displayed FTP settings, ie. the set of settings with the valid "depends" dependency. Is there a way to make it write all settings, in this case, the settings for all FTP entries, not just the single set that are visible?
While not a direct answer to your question, you may want to consider using TypedSection (with or without cbi/tblsection template )and show the FTP picker drop-down above that.
I ended up resolving this by saving settings at parse time, and writing back non-visible settings manually, like this:
local FTPIPAddress = {}
local FTPUsername = {}
local FTPPassword = {}
local FTPDirectory = {}
local FTPOptions = 10
function m.on_after_save(map)
local SelectFTP = uci:get("syncit_dest", "main", "SelectFTP")
local index = 1
for i=1, FTPOptions do
if SelectFTP == "ftp" .. i then
index = i
end
end
for i=1, FTPOptions do
if i ~= index then
uci:set("syncit_dest", "main", "FTPIPAddress" .. i, FTPIPAddress[i] )
uci:set("syncit_dest", "main", "FTPUsername" .. i, FTPUsername[i] )
uci:set("syncit_dest", "main", "FTPPassword" .. i, FTPPassword[i] )
uci:set("syncit_dest", "main", "FTPDirectory" .. i, FTPDirectory[i] )
end
end
exec("uci commit")
end
function m.on_parse(map)
for i=1, FTPOptions do
FTPIPAddress[i] = uci:get("syncit_dest", "main", "FTPIPAddress" .. i)
FTPUsername[i] = uci:get("syncit_dest", "main", "FTPUsername" .. i)
FTPPassword[i]= uci:get("syncit_dest", "main", "FTPPassword" .. i)
FTPDirectory[i]= uci:get("syncit_dest", "main", "FTPDirectory" .. i)
end
end