summaryrefslogtreecommitdiffstats
path: root/Sluift
diff options
context:
space:
mode:
Diffstat (limited to 'Sluift')
-rw-r--r--Sluift/core.lua19
1 files changed, 12 insertions, 7 deletions
diff --git a/Sluift/core.lua b/Sluift/core.lua
index ecd3c5e..616d96c 100644
--- a/Sluift/core.lua
+++ b/Sluift/core.lua
@@ -448,18 +448,23 @@ _H = {
{"form_type", "If specified, add a form_type field with this value"},
{"type", "Form type, e.g. 'submit'"} }
}
-local function create_form(fields, ...)
+local function create_form(...)
local options = parse_options({}, ...)
local result = { fields = {} }
- for var, value in pairs(fields) do
- result.fields[#result.fields+1] = { name = var, value = value }
+ -- FIXME: make nicer when parse_options binds positional arguments to names
+ if options.fields then
+ for var, value in pairs(options.fields) do
+ result.fields[#result.fields+1] = { name = var, value = value }
+ end
+ elseif options[1] then
+ for var, value in pairs(options[1]) do
+ result.fields[#result.fields+1] = { name = var, value = value }
+ end
end
if options.form_type then
- result.fields[#result.fields+1] = { name = 'form_type', value = form_type }
- end
- if options.type then
- result['type'] = type
+ result.fields[#result.fields+1] = { name = 'FORM_TYPE', value = options.form_type }
end
+ result['type'] = options.type
return result
end