Diff

util/dataforms.lua @ 8255:d70d4c1ac17a

util.dataforms: Don't include list options in result forms (fixes #983)
author Matthew Wild <mwild1@gmail.com>
date Sat, 23 Sep 2017 13:20:46 +0100
parent 7446:0db72fac2faa
child 8555:4f0f5b49bb03
line wrap: on
line diff
--- a/util/dataforms.lua	Sun Sep 17 13:29:14 2017 -0400
+++ b/util/dataforms.lua	Sat Sep 23 13:20:46 2017 +0100
@@ -68,33 +68,37 @@
 					form:tag("value"):text(line):up();
 				end
 			elseif field_type == "list-single" then
-				local has_default = false;
-				for _, val in ipairs(field.options or value) do
-					if type(val) == "table" then
-						form:tag("option", { label = val.label }):tag("value"):text(val.value):up():up();
-						if value == val.value or val.default and (not has_default) then
-							form:tag("value"):text(val.value):up();
-							has_default = true;
+				if formtype ~= "result" then
+					local has_default = false;
+					for _, val in ipairs(field.options or value) do
+						if type(val) == "table" then
+							form:tag("option", { label = val.label }):tag("value"):text(val.value):up():up();
+							if value == val.value or val.default and (not has_default) then
+								form:tag("value"):text(val.value):up();
+								has_default = true;
+							end
+						else
+							form:tag("option", { label= val }):tag("value"):text(tostring(val)):up():up();
 						end
-					else
-						form:tag("option", { label= val }):tag("value"):text(tostring(val)):up():up();
 					end
 				end
-				if field.options and value then
+				if (field.options or formtype == "result") and value then
 					form:tag("value"):text(value):up();
 				end
 			elseif field_type == "list-multi" then
-				for _, val in ipairs(field.options or value) do
-					if type(val) == "table" then
-						form:tag("option", { label = val.label }):tag("value"):text(val.value):up():up();
-						if not field.options and val.default then
-							form:tag("value"):text(val.value):up();
+				if formtype ~= "result" then
+					for _, val in ipairs(field.options or value) do
+						if type(val) == "table" then
+							form:tag("option", { label = val.label }):tag("value"):text(val.value):up():up();
+							if not field.options and val.default then
+								form:tag("value"):text(val.value):up();
+							end
+						else
+							form:tag("option", { label= val }):tag("value"):text(tostring(val)):up():up();
 						end
-					else
-						form:tag("option", { label= val }):tag("value"):text(tostring(val)):up():up();
 					end
 				end
-				if field.options and value then
+				if (field.options or formtype == "result") and value then
 					for _, val in ipairs(value) do
 						form:tag("value"):text(val):up();
 					end