mod_server_contact_info: Use more explicit value data format for dataform

Sat, 01 Oct 2016 17:16:23 +0200

author
Kim Alvefur <zash@zash.se>
date
Sat, 01 Oct 2016 17:16:23 +0200
changeset 2319
86128b948fed
parent 2318
3e5828e3f17f
child 2320
d6a3362ca256

mod_server_contact_info: Use more explicit value data format for dataform

mod_server_contact_info/mod_server_contact_info.lua file | annotate | diff | comparison | revisions
--- a/mod_server_contact_info/mod_server_contact_info.lua	Sat Oct 01 17:15:03 2016 +0200
+++ b/mod_server_contact_info/mod_server_contact_info.lua	Sat Oct 01 17:16:23 2016 +0200
@@ -31,10 +31,19 @@
 };
 local form_values = {};
 
-for t,a in pairs(contact_config) do
-	if valid_types[t] and a then
+for t in pairs(valid_types) do
+	local addresses = contact_config[t];
+	if addresses then
 		t_insert(form_layout, { name = t .. "-addresses", type = "list-multi" });
-		form_values[t .. "-addresses"] = type(a) == "table" and a or {a};
+		local values = {};
+		if type(addresses) ~= "table" then
+			values[1] = { value = addresses };
+		else
+			for i, address in ipairs(addresses) do
+				values[i] = { value = address };
+			end
+		end
+		form_values[t .. "-addresses"] = values;
 	end
 end
 

mercurial