Diff

util/dataforms.lua @ 9094:05979ae1e38a

util.dataforms: Only allow overriding of options when passed via the :form method
author Kim Alvefur <zash@zash.se>
date Fri, 03 Aug 2018 22:55:28 +0200
parent 9092:5110da3a71eb
child 9111:bc7473fb7ad3
line wrap: on
line diff
--- a/util/dataforms.lua	Fri Aug 03 22:25:16 2018 +0200
+++ b/util/dataforms.lua	Fri Aug 03 22:55:28 2018 +0200
@@ -50,18 +50,17 @@
 			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