How To Call It
Form is a global table: call its functions with a dot (Form.<method>(...)), not a colon. Requires Macro Handler 1.0.51 or later.
Builds and opens the form; returns a value table on acceptance or nil on cancellation or timeout.
Documented for app version 1.0.50Updated:
Form is a global table: call its functions with a dot (Form.<method>(...)), not a colon. Requires Macro Handler 1.0.51 or later.
Builds and opens the form; returns a value table on acceptance or nil on cancellation or timeout.
The schema contains a fields array and optional title, positive, negative, surface and timeoutMs. Field types include input, checkbox, radio, select, multi, tags, signature, image, color, file, datetime, range, slider, recorder, navigation and agentDetect; layouts include text/spacer, row/section and tabs. Keys must be unique; radio/select/tabs selected indices start at 1. Up to 256 fields and 8 layout levels are accepted.
Use visibleWhen = {{key="enabled", value=true}} for conditional visibility and required, pattern, help and style for field rules. Cyclic visibility and invalid schemas are rejected. Form uses the shared Setting renderer; it does not execute custom HTML or external code. Checkbox defaults are boolean; other values are strings. Radio/select and tabs return the selected label; multi returns comma-separated labels. Use tonumber before numeric operations.
The snippet below is a starter pattern that can be applied directly in runtime flow.
local schema = {title = "Run settings", positive = "Start", negative = "Cancel", fields = {
{type = "checkbox", key = "enabled", label = "Enabled", value = true},
{type = "input", key = "target", label = "Target", value = "Example", required = true},
{type = "slider", key = "count", label = "Count", min = 1, max = 10, value = 3},
{type = "select", key = "mode", options = {"Safe", "Fast"}, selected = 2},
{type = "multi", key = "steps", label = "Steps", options = {"Scan", "Report"}, value = {"Scan"}}
}}
local values = Form.show(schema)
if values ~= nil and values.enabled then
local count = tonumber(values.count)
if count then print(values.target, values.mode, count) end
endFrom foundation to combined usage, each level is provided as a separate code block so you can copy the level you need and adapt it directly.
local schema = {title = "Run settings", positive = "Start", negative = "Cancel", fields = {
{type = "checkbox", key = "enabled", label = "Enabled", value = true},
{type = "input", key = "target", label = "Target", value = "Example", required = true},
{type = "slider", key = "count", label = "Count", min = 1, max = 10, value = 3},
{type = "select", key = "mode", options = {"Safe", "Fast"}, selected = 2},
{type = "multi", key = "steps", label = "Steps", options = {"Scan", "Report"}, value = {"Scan"}}
}}
local values = Form.show(schema)
if values ~= nil and values.enabled then
local count = tonumber(values.count)
if count then print(values.target, values.mode, count) end
endlocal stepOk = true
local schema = {title = "Run settings", positive = "Start", negative = "Cancel", fields = {
{type = "checkbox", key = "enabled", label = "Enabled", value = true},
{type = "input", key = "target", label = "Target", value = "Example", required = true},
{type = "slider", key = "count", label = "Count", min = 1, max = 10, value = 3},
{type = "select", key = "mode", options = {"Safe", "Fast"}, selected = 2},
{type = "multi", key = "steps", label = "Steps", options = {"Scan", "Report"}, value = {"Scan"}}
}}
local values = Form.show(schema)
if values ~= nil and values.enabled then
local count = tonumber(values.count)
if count then print(values.target, values.mode, count) end
end
if stepOk then
wait(200)
endlocal ok, err = pcall(function()
local schema = {title = "Run settings", positive = "Start", negative = "Cancel", fields = {
{type = "checkbox", key = "enabled", label = "Enabled", value = true},
{type = "input", key = "target", label = "Target", value = "Example", required = true},
{type = "slider", key = "count", label = "Count", min = 1, max = 10, value = 3},
{type = "select", key = "mode", options = {"Safe", "Fast"}, selected = 2},
{type = "multi", key = "steps", label = "Steps", options = {"Scan", "Report"}, value = {"Scan"}}
}}
local values = Form.show(schema)
if values ~= nil and values.enabled then
local count = tonumber(values.count)
if count then print(values.target, values.mode, count) end
end
end)
if not ok then
print("API step failed: Form.show: " .. tostring(err))
requestStop()
end-- Form.show(schema)
local function run_show_step()
local schema = {title = "Run settings", positive = "Start", negative = "Cancel", fields = {
{type = "checkbox", key = "enabled", label = "Enabled", value = true},
{type = "input", key = "target", label = "Target", value = "Example", required = true},
{type = "slider", key = "count", label = "Count", min = 1, max = 10, value = 3},
{type = "select", key = "mode", options = {"Safe", "Fast"}, selected = 2},
{type = "multi", key = "steps", label = "Steps", options = {"Scan", "Report"}, value = {"Scan"}}
}}
local values = Form.show(schema)
if values ~= nil and values.enabled then
local count = tonumber(values.count)
if count then print(values.target, values.mode, count) end
end
end
local ok, err = pcall(run_show_step)
if not ok then
toast("Step failed")
print(err)
endlocal schema = {title = "Run settings", positive = "Start", negative = "Cancel", fields = {
{type = "checkbox", key = "enabled", label = "Enabled", value = true},
{type = "input", key = "target", label = "Target", value = "Example", required = true},
{type = "slider", key = "count", label = "Count", min = 1, max = 10, value = 3},
{type = "select", key = "mode", options = {"Safe", "Fast"}, selected = 2},
{type = "multi", key = "steps", label = "Steps", options = {"Scan", "Report"}, value = {"Scan"}}
}}
local values = Form.show(schema)
if values ~= nil and values.enabled then
local count = tonumber(values.count)
if count then print(values.target, values.mode, count) end
end