Software /
code /
prosody
Comparison
util/dataforms.lua @ 4928:5211c11dd865
util.dataforms: Fix parsing of -multi fields
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Tue, 12 Jun 2012 18:29:58 +0200 |
parent | 4887:4dd61fe04db4 |
child | 5551:e1e06f1465be |
comparison
equal
deleted
inserted
replaced
4926:58714123f600 | 4928:5211c11dd865 |
---|---|
183 | 183 |
184 field_readers["list-multi"] = | 184 field_readers["list-multi"] = |
185 function (field_tag, required) | 185 function (field_tag, required) |
186 local result = {}; | 186 local result = {}; |
187 for value in field_tag:childtags("value") do | 187 for value in field_tag:childtags("value") do |
188 result[#result+1] = value; | 188 result[#result+1] = value:get_text(); |
189 end | 189 end |
190 return result, (required and #result == 0 and "Required value missing" or nil); | 190 return result, (required and #result == 0 and "Required value missing" or nil); |
191 end | 191 end |
192 | 192 |
193 field_readers["text-multi"] = | 193 field_readers["text-multi"] = |
200 end | 200 end |
201 | 201 |
202 field_readers["list-single"] = | 202 field_readers["list-single"] = |
203 field_readers["text-single"]; | 203 field_readers["text-single"]; |
204 | 204 |
205 local boolean_values = { | 205 local boolean_values = { |
206 ["1"] = true, ["true"] = true, | 206 ["1"] = true, ["true"] = true, |
207 ["0"] = false, ["false"] = false, | 207 ["0"] = false, ["false"] = false, |
208 }; | 208 }; |
209 | 209 |
210 field_readers["boolean"] = | 210 field_readers["boolean"] = |
211 function (field_tag, required) | 211 function (field_tag, required) |
212 local raw_value = field_tag:get_child_text("value"); | 212 local raw_value = field_tag:get_child_text("value"); |
213 local value = boolean_values[raw_value ~= nil and raw_value]; | 213 local value = boolean_values[raw_value ~= nil and raw_value]; |