summaryrefslogtreecommitdiffstats
path: root/Sluift
diff options
context:
space:
mode:
authorEdwin Mons <edwin.mons@isode.com>2014-05-12 14:41:33 (GMT)
committerEdwin Mons <edwin.mons@isode.com>2014-05-12 14:41:33 (GMT)
commita2bd9984a31e426e2ba263e68e6dc0733970026c (patch)
treeb76f16bb0b20771fd40ad36d8144713a335b5d9f /Sluift
parente5fc9da99eae0d54b4ff5607016fbacfdbf55485 (diff)
downloadswift-a2bd9984a31e426e2ba263e68e6dc0733970026c.zip
swift-a2bd9984a31e426e2ba263e68e6dc0733970026c.tar.bz2
Fix create_form to work properly with fields
Change-Id: I02f2ec421bd7ba54f64eff35dc1c6e21a7c22545
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