Diff

util/dataforms.lua @ 3379:17d4298b2a58

util.dataforms: Capability to set default for list-single
author Florian Zeitz <florob@babelmonkeys.de>
date Thu, 15 Jul 2010 21:31:57 +0200
parent 2923:b7049746bd29
child 3380:e74e80b454a1
line wrap: on
line diff
--- a/util/dataforms.lua	Thu Jul 15 21:14:07 2010 +0200
+++ b/util/dataforms.lua	Thu Jul 15 21:31:57 2010 +0200
@@ -67,9 +67,14 @@
 					form:tag("value"):text(line):up();
 				end
 			elseif field_type == "list-single" then
+				local has_default = false;
 				for _, val in ipairs(value) do
 					if type(val) == "table" then
 						form:tag("option", { label = val.label }):tag("value"):text(val.value):up():up();
+						if 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