Skip to content
Discussion options

You must be logged in to vote

You don’t need set_options for this. A field’s options is an ordinary Lua table, so you can build the list before you open the form. opensak.databases() returns one table per database (name, path, active, size_mb), not plain strings, so collect the names first:

local names, current = {}, nil
for _, db in ipairs(opensak.databases()) do
names[#names + 1] = db.name
if db.active then current = db.name end
end

local v = opensak.form{
title = "Choose database",
fields = {
{ type = "choice", id = "db", label = "Database",
options = names, default = current },
},
}
if not v then return end -- cancelled

print("Selected: " .. v.db)
-- e.g. read it without switching:
-- for c in opensak.caches{ data…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ianwok
Comment options

Answer selected by AgreeDK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
FAQ
Labels
None yet
2 participants