From 4e6aa6ffd254b1a9415a0b0553df8d95a6f4e3d9 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 3 Aug 2018 22:55:28 +0200 Subject: util.dataforms: Only allow overriding of options when passed via the :form method --- util/dataforms.lua | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/util/dataforms.lua b/util/dataforms.lua index 72394fd8..45af72d1 100644 --- a/util/dataforms.lua +++ b/util/dataforms.lua @@ -50,18 +50,17 @@ function form_t.form(layout, data, formtype) end end - local value; + local value = field.value; + local options = field.options; + if data and data[field.name] ~= nil then value = data[field.name]; - else - value = field.value; - end - local options = field.options; - if formtype == "form" and value - and (field_type == "list-single" or field_type == "list-multi") then - -- Allow passing dynamically generated options as values - options, value = value, nil; + if formtype == "form" and type(value) == "table" + and (field_type == "list-single" or field_type == "list-multi") then + -- Allow passing dynamically generated options as values + options, value = value, nil; + end end if formtype == "form" and options then -- cgit v1.2.3