From a2bd9984a31e426e2ba263e68e6dc0733970026c Mon Sep 17 00:00:00 2001 From: Edwin Mons Date: Mon, 12 May 2014 16:41:33 +0200 Subject: Fix create_form to work properly with fields Change-Id: I02f2ec421bd7ba54f64eff35dc1c6e21a7c22545 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 -- cgit v0.10.2-6-g49f6