Changeset

2319:86128b948fed

mod_server_contact_info: Use more explicit value data format for dataform
author Kim Alvefur <zash@zash.se>
date Sat, 01 Oct 2016 17:16:23 +0200
parents 2318:3e5828e3f17f
children 2320:d6a3362ca256
files mod_server_contact_info/mod_server_contact_info.lua
diffstat 1 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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